def test_encoder_learnt_sink(self): # Create a network and standard model with nengo.Network(): a = nengo.Ensemble(100, 2) b = nengo.Ensemble(100, 2) a_b = nengo.Connection(a, b) a_b.learning_rule_type = nengo.Voja() # Create a model with the Ensemble for b in it model = builder.Model() b_ens = operators.EnsembleLIF(b) model.object_operators[b] = b_ens sink = ensemble.get_ensemble_sink(model, a_b) assert sink.target.obj is b_ens assert sink.target.port is ensemble.EnsembleInputPort.learnt
def test_constant_node_sink_with_slice(self): """Test that connections from constant valued Nodes to Ensembles are optimised out correctly. """ # Create a network and standard model with nengo.Network(): a = nengo.Node([0.5, 1.0]) b = nengo.Ensemble(200, 2) a_b = nengo.Connection(a[0], b[1]) # Create a model with the Ensemble for b in it model = builder.Model() b_ens = operators.EnsembleLIF(b) model.object_operators[b] = b_ens # Check that no sink is created but that the direct input is modified assert np.all(b_ens.direct_input == np.zeros(2)) assert ensemble.get_ensemble_sink(model, a_b) is None assert np.all(b_ens.direct_input == [0.0, 0.5])
def test_normal_sink_for_process_node(self): """Test that sinks for most connections into Ensembles do nothing special. """ # Create a network and standard model with nengo.Network(): a = nengo.Node(nengo.processes.WhiteNoise(), size_out=4) b = nengo.Ensemble(200, 4) a_b = nengo.Connection(a, b) # Create a model with the Ensemble for b in it model = builder.Model() b_ens = operators.EnsembleLIF(b) model.object_operators[b] = b_ens # Get the sink, check that an appropriate target is return sink = ensemble.get_ensemble_sink(model, a_b) assert sink.target.obj is b_ens assert sink.target.port is InputPort.standard
def test_normal_sink_for_process_node(self): """Test that sinks for most connections into Ensembles do nothing special. """ # Create a network and standard model with nengo.Network(): a = nengo.Node(nengo.processes.WhiteNoise(), size_out=4) b = nengo.Ensemble(200, 4) a_b = nengo.Connection(a, b) # Create a model with the Ensemble for b in it model = builder.Model() b_ens = operators.EnsembleLIF(b) model.object_operators[b] = b_ens # Get the sink, check that an appropriate target is return sink = ensemble.get_ensemble_sink(model, a_b) assert sink.target.obj is b_ens assert sink.target.port is builder.InputPort.standard