def test_continuous_signal_events(self): dtype = np.dtype([('time', np.float64)]) model_description = ModelDescription() # no event signals = np.array([(0,), (1,)], dtype=dtype) t_events = Input.findEvents(signals, model_description) self.assertEqual([inf], t_events) # time grid with events at 0.5 and 0.8 signals = np.array(list(zip([0.1, 0.2, 0.3, 0.4, 0.5, 0.5, 0.6, 0.7, 0.8, 0.8, 0.8, 0.9, 1.0])), dtype=dtype) t_events = Input.findEvents(signals, model_description) self.assertTrue(np.all([0.5, 0.8, inf] == t_events))
def test_discrete_signal_events(self): # model with one discrete variable 'x' model_description = ModelDescription() variable = ScalarVariable('x', 0) variable.variability = 'discrete' model_description.modelVariables.append(variable) # discrete events at 0.1 and 0.4 signals = np.array([(0.0, 0), (0.1, 0), (0.2, 1), (0.3, 1), (0.4, 2)], dtype=np.dtype([('time', np.float64), ('x', np.int)])) t_event = Input.findEvents(signals, model_description) self.assertTrue(np.all([0.2, 0.4, inf] == t_event))