Exemple #1
0
    def test_merge(self):
        test_array_1 = np.array([[1, 2], [3, 5], [4, 5], [4, 8]])

        test_array_2 = np.array([[4, 3], [5, 4], [6, 1], [8, 8]])

        test_array_check = np.array([[1, 2], [3, 5], [4, 5], [4, 8], [4, 3],
                                     [5, 4], [6, 1], [8, 8]])

        x1 = test_array_1[:, 0]
        y1 = test_array_1[:, 1]
        x2 = test_array_2[:, 0]
        y2 = test_array_2[:, 1]
        x_check = test_array_check[:, 0]
        y_check = test_array_check[:, 1]

        c1 = CorrelationList(1)
        c1.update(0, x1, y1)

        c2 = CorrelationList(1)
        c2.update(0, x2, y2)

        c3 = CorrelationList(1)
        c3.merge(c1)
        c3.merge(c2)

        self.assertAlmostEqual(c3[0],
                               np.corrcoef(x_check, y_check)[1, 0],
                               places=13)
Exemple #2
0
    def test_update(self):
        test_array = np.array([[1, 2], [3, 5], [4, 5], [4, 8]])
        x = test_array[:, 0]
        y = test_array[:, 1]

        clist1 = CorrelationList(1)
        clist1.update(0, x, y)
        clist2 = CorrelationList([1, 1])
        clist2.update((0, 0), x, y)

        # Checks
        self.assertAlmostEqual(clist1[0], np.corrcoef(x, y)[1, 0], places=13)
        self.assertAlmostEqual(clist2[0, 0],
                               np.corrcoef(x, y)[1, 0],
                               places=13)
Exemple #3
0
    def test_max(self):
        test_array_1 = np.array([[1, 2], [3, 5], [4, 5], [4, 8]])

        test_array_2 = np.array([[4, 3], [5, 4], [6, 1], [8, 8]])

        test_array_3 = np.array([[-1, 1], [-2, 2], [-3, 3], [-4, 4]])

        x1 = test_array_1[:, 0]
        y1 = test_array_1[:, 1]
        x2 = test_array_2[:, 0]
        y2 = test_array_2[:, 1]
        x3 = test_array_3[:, 0]
        y3 = test_array_3[:, 1]

        clist = CorrelationList([1, 3])
        clist.update((0, 0), x1, y1)
        clist.update((0, 1), x2, y2)
        clist.update((0, 2), x3, y3)

        max_corr_over_points = np.max(np.abs(clist[0, :]))
        self.assertEqual(max_corr_over_points, 1.0)