Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
 def test_transform_before_fit(self):
     a = SineMatrix()
     with self.assertRaises(ValueError):
         a.transform([H])
Exemplo n.º 7
0
 def test_small_to_large_transform(self):
     a = SineMatrix(input_type=H_INPUT)
     a.fit([H])
     with self.assertRaises(ValueError):
         a.transform([H2])
Exemplo n.º 8
0
 def test_fit(self):
     a = SineMatrix()
     a.fit([(H2_ELES, H2_COORDS)])
     self.assertEqual(a._max_size, 2)
Exemplo n.º 9
0
 def test_transform_before_fit(self):
     a = SineMatrix()
     with self.assertRaises(ValueError):
         a.transform([H])
Exemplo n.º 10
0
 def test_small_to_large_transform(self):
     a = SineMatrix(input_type=H_INPUT)
     a.fit([H])
     with self.assertRaises(ValueError):
         a.transform([H2])
Exemplo n.º 11
0
 def test_fit(self):
     a = SineMatrix()
     a.fit([(H2_ELES, H2_COORDS)])
     self.assertEqual(a._max_size, 2)