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())
def test_transform(self): a = Autocorrelation(depths=[1], properties=['I']) a.fit(ALL_DATA) expected = numpy.array([ [8], [8], [104], ]) self.assertTrue((a.transform(ALL_DATA) == expected).all())
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())
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())
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)
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())
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())