Exemplo n.º 1
0
 def test_get_labels_eigen(self):
     a = CoulombMatrix(eigen=True)
     X = a.fit_transform([METHANE])
     labels = a.get_labels()
     self.assertEqual(X.shape[1], len(labels))
     expected = ('coul-0', 'coul-1', 'coul-2', 'coul-3', 'coul-4')
     self.assertEqual(labels, expected)
Exemplo n.º 2
0
 def test_get_labels(self):
     a = CoulombMatrix()
     X = a.fit_transform([METHANE])
     labels = a.get_labels()
     self.assertEqual(X.shape[1], len(labels))
     expected = (
         'coul-0-0',
         'coul-0-1',
         'coul-0-2',
         'coul-0-3',
         'coul-0-4',
         'coul-1-0',
         'coul-1-1',
         'coul-1-2',
         'coul-1-3',
         'coul-1-4',
         'coul-2-0',
         'coul-2-1',
         'coul-2-2',
         'coul-2-3',
         'coul-2-4',
         'coul-3-0',
         'coul-3-1',
         'coul-3-2',
         'coul-3-3',
         'coul-3-4',
         'coul-4-0',
         'coul-4-1',
         'coul-4-2',
         'coul-4-3',
         'coul-4-4',
     )
     self.assertEqual(labels, expected)
Exemplo n.º 3
0
    def test_eigen(self):
        a = CoulombMatrix(eigen=True)

        expected_results = numpy.array(
            [40.04619974, -1.00605888, -0.06059994, -0.06071616, -0.06071957])
        try:
            numpy.testing.assert_array_almost_equal(
                a.fit_transform([METHANE])[0], expected_results)
        except AssertionError as e:
            self.fail(e)
Exemplo n.º 4
0
 def test_only_lower_triangle(self):
     a = CoulombMatrix(only_lower_triangle=True)
     expected_results = numpy.array([36.858105, 5.49459, 0.5, 5.494629,
                                     0.560719, 0.5, 5.4945, 0.560717,
                                     0.560718, 0.5, 5.490313, 0.56064,
                                     0.560641, 0.560638, 0.5])
     try:
         numpy.testing.assert_array_almost_equal(
             a.fit_transform([METHANE])[0],
             expected_results)
     except AssertionError as e:
         self.fail(e)
Exemplo n.º 5
0
 def test_fit_transform(self):
     a = CoulombMatrix()
     expected_results = numpy.array([[
         36.8581052, 5.49459021, 5.49462885, 5.4945, 5.49031286, 5.49459021,
         0.5, 0.56071947, 0.56071656, 0.56064037, 5.49462885, 0.56071947,
         0.5, 0.56071752, 0.56064089, 5.4945, 0.56071656, 0.56071752, 0.5,
         0.56063783, 5.49031286, 0.56064037, 0.56064089, 0.56063783, 0.5
     ]])
     try:
         numpy.testing.assert_array_almost_equal(a.fit_transform([METHANE]),
                                                 expected_results)
     except AssertionError as e:
         self.fail(e)
Exemplo n.º 6
0
    def test_sort(self):
        a = CoulombMatrix(sort=True)
        b = CoulombMatrix()

        res_a = a.fit_transform([MID])
        res_b = b.fit_transform([MID])
        self.assertFalse(numpy.allclose(res_a, res_b))
        expected_results = numpy.array([
            73.51669472, 45.84796673, 20.4393443, 18.51709592, 34.38200956,
            19.92342035, 1.71317156, 1.39374152, 1.20676731
        ])

        try:
            numpy.testing.assert_array_almost_equal(res_a[0, :9],
                                                    expected_results)
        except AssertionError as e:
            self.fail(e)
Exemplo n.º 7
0
 def test_transform_before_fit(self):
     a = CoulombMatrix()
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)
Exemplo n.º 8
0
 def test_small_to_large_transform_drop_values(self):
     a = CoulombMatrix(drop_values=True)
     a.fit([METHANE])
     a.transform(ALL_DATA)
     self.assertEqual(a.transform(ALL_DATA).shape, (3, 25))
Exemplo n.º 9
0
 def test_small_to_large_transform(self):
     a = CoulombMatrix()
     a.fit([METHANE])
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)
Exemplo n.º 10
0
 def test_fit(self):
     a = CoulombMatrix()
     a.fit(ALL_DATA)
     self.assertEqual(a._max_size, 49)