def test_set_params(self): sin = SinusoidalInput( stim_start=STIM_START, stim_end=STIM_END, amplitude=self.AMPLITUDE, period=self.PERIOD, num_iid=2, seed=42, ) UPDATE = {"amplitude": 43.0, "seed": 12} sin.update_params(UPDATE) params = sin.get_params() params.pop("type") self.assertDictEqual( params, { "num_iid": 2, "seed": 42, "period": self.PERIOD, "amplitude": self.AMPLITUDE, "stim_start": STIM_START, "nonnegative": True, "stim_end": STIM_END, **UPDATE, }, )
def test_generate_input(self): sin = SinusoidalInput( duration=DURATION, dt=DT, amplitude=self.AMPLITUDE, period=self.PERIOD, independent_realisations=2, seed=42, ).generate_input() self.assertTrue(isinstance(sin, np.ndarray)) self.assertTupleEqual(sin.shape, SHAPE) np.testing.assert_equal(np.mean(sin, axis=0), np.array(2 * [self.AMPLITUDE]))
def test_start_end_input(self): sin = SinusoidalInput( stim_start=STIM_START, stim_end=STIM_END, amplitude=self.AMPLITUDE, period=self.PERIOD, num_iid=2, seed=42, ).as_array(duration=DURATION, dt=DT) np.testing.assert_allclose(sin[:int(STIM_START / DT) - 1, :], 0.0) np.testing.assert_allclose(sin[int(STIM_END / DT):, :], 0.0)