Пример #1
0
    def test_HawkesKernelPowerLaw_pickle(self):
        """...Test pickling ability of HawkesKernelPowerLaw
        """
        obj = HawkesKernelPowerLaw(0.1, 0.01, 1.2)
        pickled = pickle.loads(pickle.dumps(obj))

        self.assertTrue(str(obj) == str(pickled))
        np.testing.assert_array_equal(obj.get_values(self.random_times),
                                      obj.get_values(self.random_times))
Пример #2
0
    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)
Пример #3
0
    def test_HawkesKernelPowerLaw_repr(self):
        """...Test HawkesKernelPowerLaw string in list representation
        """
        multiplier = 0.1
        cutoff = 0.01
        exponent = 1.2
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(str([hawkes_kernel_power_law]),
                         "[0.1*(0.01+t)^(-1.2)]")

        multiplier = 0
        cutoff = 0.01
        exponent = 1.2
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(str([hawkes_kernel_power_law]), "[0]")

        multiplier = 0.1
        cutoff = 0.01
        exponent = 0
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(str([hawkes_kernel_power_law]), "[0.1]")
Пример #4
0
    def test_HawkesKernelPowerLaw_str(self):
        """...Test HawkesKernelPowerLaw string representation
        """
        multiplier = 0.1
        cutoff = 0.01
        exponent = 1.2
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(str(hawkes_kernel_power_law),
                         "0.1 * (0.01 + t)^(-1.2)")

        multiplier = 0
        cutoff = 0.01
        exponent = 1.2
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(str(hawkes_kernel_power_law), "0")

        multiplier = 0.1
        cutoff = 0.01
        exponent = 0
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(str(hawkes_kernel_power_law), "0.1")
Пример #5
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)
Пример #6
0
    def test_HawkesKernelPowerLaw_strtex(self):
        """...Test HawkesKernelPowerLaw latex string representation
        """
        multiplier = 0.1
        cutoff = 0.01
        exponent = 1.2
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(hawkes_kernel_power_law.__strtex__(),
                         "$0.1 (0.01+t)^{-1.2}$")

        multiplier = 0
        cutoff = 0.01
        exponent = 1.2
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(hawkes_kernel_power_law.__strtex__(), "$0$")

        multiplier = 0.1
        cutoff = 0.01
        exponent = 0
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(hawkes_kernel_power_law.__strtex__(), "$0.1$")

        multiplier = 1
        cutoff = 0.01
        exponent = 1.2
        hawkes_kernel_power_law = HawkesKernelPowerLaw(multiplier, cutoff,
                                                       exponent)
        self.assertEqual(hawkes_kernel_power_law.__strtex__(),
                         "$(0.01+t)^{-1.2}$")
Пример #7
0
 def setUp(self):
     self.multiplier = 0.1
     self.cutoff = 0.01
     self.exponent = 1.2
     self.hawkes_kernel_power_law = HawkesKernelPowerLaw(
         self.multiplier, self.cutoff, self.exponent)