def test_eigen(self): a = SineMatrix(input_type=H_INPUT, eigen=True) res = a.fit_transform([H2]) expected = numpy.array([[0.975557, 0.024443]]) try: numpy.testing.assert_array_almost_equal(res, expected) except AssertionError as e: self.fail(e)
def test_large_to_small_transform(self): a = SineMatrix(input_type=H_INPUT) a.fit([H2]) res = a.transform([H]) expected = numpy.array([[0.5, 0., 0., 0.]]) try: numpy.testing.assert_array_almost_equal(res, expected) except AssertionError as e: self.fail(e)
def test_eigen(self): a = SineMatrix(input_type=H_INPUT, eigen=True) res = a.fit_transform([H2]) expected = numpy.array([[0.975557, 0.024443]]) try: numpy.testing.assert_array_almost_equal( res, expected) except AssertionError as e: self.fail(e)
def test_large_to_small_transform(self): a = SineMatrix(input_type=H_INPUT) a.fit([H2]) res = a.transform([H]) expected = numpy.array([[0.5, 0., 0., 0.]]) try: numpy.testing.assert_array_almost_equal( res, expected) except AssertionError as e: self.fail(e)
0: {1: '1'}, 1: {0: '1'}, } H2_UNIT = numpy.array([ [2., .5, 0.], [.25, 1., 0.], [0., .3, 1.], ]) radius = 4.1 input_type = ("elements", "coords", "unit_cell") X = (H2_ELES, H2_COORDS, H2_UNIT) if __name__ == "__main__": trans = EwaldSumMatrix(input_type=input_type, G_max=3.2, L_max=2.1) res = trans.fit_transform([X]) print(res) trans = SineMatrix(input_type=input_type) res = trans.fit_transform([X]) print(res) # Example of generallized crystal # Any transformer can be used as it just expands the molecule using the # unit cell and coordinates. cm = CoulombMatrix(input_type=input_type) trans = GenerallizedCrystal(transformer=cm, radius=radius) res = trans.fit_transform([X]) print(res)
def test_transform_before_fit(self): a = SineMatrix() with self.assertRaises(ValueError): a.transform([H])
def test_small_to_large_transform(self): a = SineMatrix(input_type=H_INPUT) a.fit([H]) with self.assertRaises(ValueError): a.transform([H2])
def test_fit(self): a = SineMatrix() a.fit([(H2_ELES, H2_COORDS)]) self.assertEqual(a._max_size, 2)