def test_value_sink_after_simulation_not_already_probed(size_in, n_steps): """Test that the post-simulation function reads back from the recording region and formats the data correctly. """ probe = mock.Mock() probe.size_in = size_in probe.sample_every = None # Create a value sink with a dummy recording region v = ValueSink(probe, 0.001) v.recording_region_mem = mock.Mock() v.recording_region_mem.read.return_value = \ b'\xff\xff\x00\x00\x00\x00\xff\xff' # Create a mock simulator which can be modified to store the probe data sim = mock.Mock() sim.data = dict() v.after_simulation(None, sim, n_steps) assert sim.data[probe].shape == (n_steps, size_in)
def test_value_sink_after_simulation_already_probed(): """Test that the post-simulation function reads back from the recording region and formats the data correctly and that the existing probe data is extended when probing has already occurred. """ probe = mock.Mock() probe.size_in = 2 probe.sample_every = None # Create a value sink with a dummy recording region v = ValueSink(probe, 0.001) v.recording_region_mem = mock.Mock() v.recording_region_mem.read.return_value = \ b'\xff\xff\x00\x00\x00\x00\xff\xff' # Create a mock simulator which can be modified to store the probe data sim = mock.Mock() sim.data = dict() sim.data[probe] = np.zeros((10, 2)) v.after_simulation(None, sim, 1) assert sim.data[probe].shape == (11, 2) assert np.all(sim.data[probe][:10] == np.zeros((10, 2)))