示例#1
0
 def test_fit_transform(self):
     a = Autocorrelation(depths=[1], properties=['I'])
     expected = numpy.array([
         [8],
         [8],
         [104],
     ])
     self.assertTrue((a.fit_transform(ALL_DATA) == expected).all())
示例#2
0
 def test_wide_depths(self):
     a = Autocorrelation(depths=[-1, 1, 4, 10, 100], properties=['I'])
     a.fit(ALL_DATA)
     expected = numpy.array([
         [0, 8, 0, 0, 0],
         [0, 8, 0, 0, 0],
         [0, 104, 216, 166, 0]
     ])
     self.assertTrue((a.transform(ALL_DATA) == expected).all())
示例#3
0
 def test_default_depths(self):
     a = Autocorrelation(properties=['I'])
     a.fit(ALL_DATA)
     expected = numpy.array([
         [5, 8, 12, 0],
         [9, 8, 2, 0],
         [49, 104, 156, 190]
     ])
     self.assertTrue((a.transform(ALL_DATA) == expected).all())
示例#4
0
 def test_property_function(self):
     a = Autocorrelation(
         depths=[1], properties=[lambda data: [2 for x in data.numbers]])
     a.fit(ALL_DATA)
     expected = numpy.array([
         [32],
         [32],
         [416],
     ])
     self.assertTrue((a.transform(ALL_DATA) == expected).all())
示例#5
0
 def test_get_labels(self):
     a = Autocorrelation(depths=[1, 2], properties=['I', 'EN'])
     X = a.fit_transform([METHANE])
     labels = a.get_labels()
     self.assertEqual(X.shape[1], len(labels))
     expected = (
         'EN_1', 'EN_2',
         'I_1', 'I_2',
     )
     self.assertEqual(labels, expected)
示例#6
0
 def test_properties(self):
     a = Autocorrelation(depths=[0])
     a.fit(ALL_DATA)
     expected = numpy.array([[20., 25.8625, 5., 2.1625, 40.],
                             [10., 74.8594, 9., 4.4571, 331.],
                             [260., 328.7049, 49., 28.1326, 1416.]])
     try:
         m = a.transform(ALL_DATA)
         numpy.testing.assert_array_almost_equal(m, expected)
     except AssertionError as e:
         self.fail(e)
示例#7
0
 def test_fit_atom_separated(self):
     a = Autocorrelation(depths=[0, 1], properties=['I', 'Z'])
     a.fit([METHANE2])
     self.assertTrue((a.transform([METHANE2]) == numpy.array([[5, 0, 40,
                                                               0]])).all())
示例#8
0
 def test_depths_properties(self):
     a = Autocorrelation(depths=[1, 2], properties=['I', 'Z'])
     a.fit([METHANE])
     self.assertTrue(
         (a.transform([METHANE]) == numpy.array([[8, 12, 48, 12]])).all())