def setUp(self): self.decay = 2 self.intensity = 3 self.hawkes_kernel_exp = HawkesKernelExp(self.intensity, self.decay) self.multiplier = 0.1 self.cutoff = 0.01 self.exponent = 1.2 self.support = 10000 self.hawkes_kernel_power_law = HawkesKernelPowerLaw( self.multiplier, self.cutoff, self.exponent, self.support)
def test_HawkesKernelExp_pickle(self): """...Test pickling ability of HawkesKernelExp """ obj = HawkesKernelExp(decay=2, intensity=3) pickled = pickle.loads(pickle.dumps(obj)) self.assertTrue(str(obj) == str(pickled)) self.assertEqual(obj.decay, pickled.decay) self.assertEqual(obj.intensity, pickled.intensity) np.testing.assert_array_equal(obj.get_values(self.random_times), obj.get_values(self.random_times))
def test_HawkesKernelExp_repr(self): """...Test HawkesKernelExp string in list representation """ intensity = 3 decay = 2 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(str([hawkes_kernel_exp]), "[3*2*exp(-2*t)]") intensity = 3 decay = 0 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(str([hawkes_kernel_exp]), "[3]") intensity = 0 decay = 2 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(str([hawkes_kernel_exp]), "[0]")
def test_HawkesKernelExp_str(self): """...Test HawkesKernelExp string representation """ intensity = 3 decay = 2 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(str(hawkes_kernel_exp), "3 * 2 * exp(- 2 * t)") intensity = 3 decay = 0 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(str(hawkes_kernel_exp), "3") intensity = 0 decay = 2 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(str(hawkes_kernel_exp), "0")
class Test(unittest.TestCase): def setUp(self): self.decay = 2 self.intensity = 3 self.hawkes_kernel_exp = HawkesKernelExp(self.intensity, self.decay) self.multiplier = 0.1 self.cutoff = 0.01 self.exponent = 1.2 self.support = 10000 self.hawkes_kernel_power_law = HawkesKernelPowerLaw(self.multiplier, self.cutoff, self.exponent, self.support) def test_is_zero(self): """...Test is_zero method of HawkesKernel""" self.assertFalse(self.hawkes_kernel_exp.is_zero()) def test_get_support(self): """...Test get_support method of HawkesKernel""" self.assertEqual(self.hawkes_kernel_power_law.get_support(), self.support) def test_get_plot_support(self): """...Test get_plot_support method of HawkesKernel""" self.assertEqual(self.hawkes_kernel_exp.get_plot_support(), self.intensity / self.decay) def test_get_value(self): """...Test get_value method of HawkesKernel""" self.assertEqual(self.hawkes_kernel_exp.get_value(3), 0.014872513059998151) def test_get_values(self): """...Test get_values method of HawkesKernel""" t_values = np.arange(5, dtype=float) np.testing.assert_array_almost_equal( self.hawkes_kernel_exp.get_values(t_values), [6, 8.120117e-01, 1.098938e-01, 1.487251e-02, 2.012776e-03] ) def test_get_norm(self): """...Test get_norm method of HawkesKernel""" self.assertEqual(self.hawkes_kernel_exp.get_norm(), self.intensity)
def test_HawkesKernelExp_strtex(self): """...Test HawkesKernelExp latex string representation """ decay = 2 intensity = 3 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(hawkes_kernel_exp.__strtex__(), "$6 e^{-2 t}$") intensity = 3 decay = 0 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(hawkes_kernel_exp.__strtex__(), "$3$") intensity = 0 decay = 2 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(hawkes_kernel_exp.__strtex__(), "$0$") intensity = 0.5 decay = 2 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(hawkes_kernel_exp.__strtex__(), "$e^{-2 t}$") decay = 1 intensity = 3 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(hawkes_kernel_exp.__strtex__(), "$3 e^{- t}$") decay = 1 intensity = 1 hawkes_kernel_exp = HawkesKernelExp(intensity, decay) self.assertEqual(hawkes_kernel_exp.__strtex__(), "$e^{-t}$")
def setUp(self): self.decay = 2 self.intensity = 3 self.hawkes_kernel_exp = HawkesKernelExp(self.intensity, self.decay)