def minus_phase_cycle(self, num_cycles: int = 50) -> None: """Runs a series of cycles for the trial minus phase. A minus phase is the trial phase where target values are not clamped output layers. Clamping the values on the output layers is the user's responsibility. Args: num_cycles: The number of cycles to run. Raises: ValueError: If num_cycles is less than 1. """ if num_cycles < 1: raise ValueError("Number of cycles must be >= 1.") self.handle(events.BeginMinusPhase()) for _ in range(num_cycles): self.handle(events.Cycle()) self.handle(events.EndMinusPhase())
def phase_cycle(self, phase: events.Phase, num_cycles: int) -> None: """Runs a series of cycles for the trial phase. Args: phase: The type of phase to cycle. num_cycles: The number of cycles to run. Raises: ValueError: If num_cycles is less than 1. """ if phase == events.NonePhase: raise ValueError("Cannot cycle 'none' phase {0}.".format( phase.name)) if num_cycles < 1: raise ValueError("Number of cycles must be >= 1.") self.handle(events.BeginPhase(phase)) for _ in range(num_cycles): for on in self.oscills.values(): self.handle( events.OscillInhibition(on.get_inhib(), on.layer_names)) self.handle(events.Cycle()) self.handle(events.EndPhase(phase))
def test_network_triggers_cycle_on_cycle_event(mocker) -> None: n = net.Net() mocker.spy(n, "_cycle") n.handle(events.Cycle()) assert n._cycle.call_count == 1
def cycle(self) -> None: """Cycles the network.""" self.handle(events.Cycle())
def test_initializing_frequency_with_incorrect_type_raises_error() -> None: with pytest.raises(TypeError): ev.Frequency(name="cycle", end_event_type=ev.Cycle())