Esempio n. 1
0
 def test_set_params(self):
     ramp = LinearRampInput(
         stim_start=STIM_START,
         stim_end=STIM_END,
         inp_max=self.INP_MAX,
         ramp_length=self.RAMP_LENGTH,
         num_iid=2,
         seed=42,
     )
     UPDATE = {"inp_max": 41.0, "seed": 12}
     ramp.update_params(UPDATE)
     params = ramp.get_params()
     params.pop("type")
     self.assertDictEqual(
         params,
         {
             "num_iid": 2,
             "seed": 42,
             "inp_max": self.INP_MAX,
             "ramp_length": self.RAMP_LENGTH,
             "stim_start": STIM_START,
             "stim_end": STIM_END,
             **UPDATE,
         },
     )
Esempio n. 2
0
 def test_start_end_input(self):
     ramp = LinearRampInput(
         stim_start=STIM_START,
         stim_end=STIM_END,
         inp_max=self.INP_MAX,
         ramp_length=self.RAMP_LENGTH,
         num_iid=2,
         seed=42,
     ).as_array(duration=DURATION, dt=DT)
     np.testing.assert_allclose(ramp[:int(STIM_START / DT) - 1, :], 0.0)
     np.testing.assert_allclose(ramp[int(STIM_END / DT):, :], 0.0)
Esempio n. 3
0
    def test_generate_input(self):

        ramp = LinearRampInput(
            inp_max=self.INP_MAX,
            ramp_length=self.RAMP_LENGTH,
            num_iid=2,
            seed=42,
        ).generate_input(duration=DURATION, dt=DT)
        self.assertTrue(isinstance(ramp, np.ndarray))
        self.assertTupleEqual(ramp.shape, SHAPE)
        np.testing.assert_equal(np.max(ramp, axis=0),
                                np.array(2 * [self.INP_MAX]))
        np.testing.assert_equal(np.min(ramp, axis=0), np.array(2 * [0.25]))