Beispiel #1
0
    def new_oscill(self,
                   name: str,
                   layer_names: List[str],
                   spec: specs.OscillSpec = None) -> None:
        """Adds a new oscillation to the network.

        Args:
            name: The name of the oscillation.
            layer_names: The names of the layers which oscillate.
            spec: The oscillation specification.

        Raises:
            ValueError: If `layer_names` do not match any existing layer
                name.
            spec.ValidationError: If the spec contains an invalid parameter
                value.

        """
        if spec is not None:
            spec.validate()

        self._validate_layer_name(*layer_names)

        on = osc.Oscill(name, layer_names, spec=spec)
        self.oscills[name] = on
        self.objs[name] = on
def test_oscill_reset_inhib_event(mocker) -> None:
    layer = lr.Layer("lr1", 3)
    theta = osc.Oscill("theta1", ["lr1", "lr2"])
    theta.cycle()
    mocker.spy(layer, "_set_kwta")
    layer.handle(ev.OscillEndInhibition(theta.layer_names))
    layer._reset_kwta.assert_called_once()
def test_oscill_reset_inhib_event(mocker) -> None:
    layer = lr.Layer("lr1", 3)
    theta = osc.Oscill("theta1", ["lr2"])
    theta.cycle()
    mocker.spy(layer, "_reset_kwta")
    layer.handle(ev.EndOscillInhibition(theta.layer_names))

    with pytest.raises(AssertionError):
        layer._reset_kwta.assert_called_once()