Example #1
0
    def test_copy(self):
        shapes_copy = np.copy(self.shapes)

        gpa = prince.GPA(copy=True)
        gpa.fit(shapes_copy)
        np.testing.assert_array_equal(self.shapes, shapes_copy)

        gpa = prince.GPA(copy=False)
        gpa.fit(shapes_copy)
        self.assertRaises(AssertionError, np.testing.assert_array_equal,
                          self.shapes, shapes_copy)
Example #2
0
 def test_fit_transform_single(self):
     """Aligning a single shape should return the same shape, just normalized."""
     gpa = prince.GPA()
     shapes = self.shapes[0:1]
     aligned_shapes = gpa.fit_transform(shapes)
     np.testing.assert_array_almost_equal(shapes / np.linalg.norm(shapes),
                                          aligned_shapes)
Example #3
0
 def test_fit_transform_equal(self):
     """In our specific case of all-same-shape circles, the shapes should
     align perfectly."""
     gpa = prince.GPA()
     aligned_shapes = gpa.fit_transform(self.shapes)
     self.assertIsInstance(aligned_shapes, np.ndarray)
     np.testing.assert_array_almost_equal(aligned_shapes[:-1],
                                          aligned_shapes[1:])
Example #4
0
 def test_transform(self):
     gpa = prince.GPA(copy=True)
     aligned_shapes = gpa.fit(self.shapes).transform(self.shapes)
     self.assertIsInstance(aligned_shapes, np.ndarray)
     self.assertEqual(self.shapes.shape, aligned_shapes.shape)
Example #5
0
    def test_fit_bad_input_size(self):
        gpa = prince.GPA()

        with self.assertRaises(ValueError):
            gpa.fit(self.shapes[0])
Example #6
0
    def test_fit_bad_init(self):
        gpa = prince.GPA(init='bad init type')

        with self.assertRaises(ValueError):
            gpa.fit(self.shapes)
Example #7
0
 def test_fit_mean(self):
     gpa = prince.GPA(init='mean')
     self.assertIsInstance(gpa.fit(self.shapes), prince.GPA)
Example #8
0
 def test_fit_random(self):
     gpa = prince.GPA(init='random')
     self.assertIsInstance(gpa.fit(self.shapes), prince.GPA)
Example #9
0
 def test_fit(self):
     gpa = prince.GPA()
     self.assertIsInstance(gpa.fit(self.shapes), prince.GPA)