Example #1
0
    def test_HawkesKernelTimeFunc_time_function(self):
        """...Test HawkesKernelTimeFunc time_function parameter
        """
        t_values = np.linspace(-1, 100, 1000)
        np.testing.assert_array_equal(
            self.hawkes_kernel_time_func.time_function.value(t_values),
            self.time_function.value(t_values))

        self.hawkes_kernel_time_func = \
            HawkesKernelTimeFunc(t_values=self.t_values, y_values=self.y_values)
        np.testing.assert_array_equal(
            self.hawkes_kernel_time_func.time_function.value(t_values),
            self.time_function.value(t_values))
Example #2
0
    def test_HawkesKernelTimeFunc_pickle(self):
        """...Test pickling ability of HawkesKernelTimeFunc
        """
        size = 10
        y_values = np.random.rand(size)
        t_values = np.arange(size, dtype=float)
        time_function = TimeFunction([t_values, y_values])
        obj = HawkesKernelTimeFunc(time_function)

        pickled = pickle.loads(pickle.dumps(obj))

        self.assertEqual(obj.time_function.value(1),
                         pickled.time_function.value(1))
        self.assertEqual(obj.time_function.value(2),
                         pickled.time_function.value(2))
        self.assertEqual(obj.time_function.value(1.5),
                         pickled.time_function.value(1.5))
        self.assertEqual(obj.time_function.value(0.75),
                         pickled.time_function.value(0.75))
        np.testing.assert_array_equal(obj.get_values(self.random_times),
                                      obj.get_values(self.random_times))
Example #3
0
class Test(unittest.TestCase):
    def setUp(self):
        size = 10
        self.y_values = np.random.rand(size)
        self.t_values = np.arange(size, dtype=float)
        self.time_function = TimeFunction([self.t_values, self.y_values])
        self.hawkes_kernel_time_func = HawkesKernelTimeFunc(self.time_function)

    def test_HawkesKernelTimeFunc_time_function(self):
        """...Test HawkesKernelTimeFunc time_function parameter
        """
        t_values = np.linspace(-1, 100, 1000)
        np.testing.assert_array_equal(
            self.hawkes_kernel_time_func.time_function.value(t_values),
            self.time_function.value(t_values))

        self.hawkes_kernel_time_func = \
            HawkesKernelTimeFunc(t_values=self.t_values, y_values=self.y_values)
        np.testing.assert_array_equal(
            self.hawkes_kernel_time_func.time_function.value(t_values),
            self.time_function.value(t_values))

    def test_HawkesKernelTimeFunc_str(self):
        """...Test HawkesKernelTimeFunc string representation
        """
        self.assertEqual(str(self.hawkes_kernel_time_func), "KernelTimeFunc")

    def test_HawkesKernelTimeFunc_repr(self):
        """...Test HawkesKernelTimeFunc string in list representation
        """
        self.assertEqual(str([self.hawkes_kernel_time_func]),
                         "[KernelTimeFunc]")

    def test_HawkesKernelTimeFunc_strtex(self):
        """...Test HawkesKernelTimeFunc string representation
        """
        self.assertEqual(self.hawkes_kernel_time_func.__strtex__(),
                         "TimeFunc Kernel")
Example #4
0
 def setUp(self):
     size = 10
     self.y_values = np.random.rand(size)
     self.t_values = np.arange(size, dtype=float)
     self.time_function = TimeFunction([self.t_values, self.y_values])
     self.hawkes_kernel_time_func = HawkesKernelTimeFunc(self.time_function)