예제 #1
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_transform(self):
     a = LocalEncodedBond()
     a.fit(ALL_DATA)
     m = a.transform(ALL_DATA)
     expected_results = numpy.array(
         [17.068978019300587, 54.629902544876572, 1006.4744899075993])
     mm = numpy.array([x.sum() for x in m])
     self.assertTrue((numpy.allclose(mm, expected_results)))
예제 #2
0
 def test_transform(self):
     a = LocalEncodedBond()
     a.fit(ALL_DATA)
     m = a.transform(ALL_DATA)
     expected_results = numpy.array([17.068978019300587,
                                     54.629902544876572,
                                     1006.4744899075993])
     mm = numpy.array([x.sum() for x in m])
     self.assertTrue((numpy.allclose(mm, expected_results)))
예제 #3
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_transform_max_depth1(self):
     a = LocalEncodedBond(max_depth=1)
     a.fit(ALL_DATA)
     m = a.transform(ALL_DATA)
     expected_results = numpy.array([6.82758723, 6.82758018, 88.75860423])
     mm = numpy.array([x.sum() for x in m])
     try:
         numpy.testing.assert_allclose(mm, expected_results)
     except AssertionError as e:
         self.fail(e)
예제 #4
0
 def test_get_labels(self):
     a = LocalEncodedBond(segments=2, start=0., end=1.)
     m = a.fit_transform([METHANE])
     labels = a.get_labels()
     self.assertEqual(m.shape[2], len(labels))
     expected = (
         'C_0.0', 'C_1.0',
         'H_0.0', 'H_1.0',
     )
     self.assertEqual(labels, expected)
예제 #5
0
 def test_transform_max_depth1(self):
     a = LocalEncodedBond(max_depth=1)
     a.fit(ALL_DATA)
     m = a.transform(ALL_DATA)
     expected_results = numpy.array([6.82758723,
                                     6.82758018,
                                     88.75860423])
     mm = numpy.array([x.sum() for x in m])
     try:
         numpy.testing.assert_allclose(mm, expected_results)
     except AssertionError as e:
         self.fail(e)
예제 #6
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_get_labels(self):
     a = LocalEncodedBond(segments=2, start=0., end=1.)
     m = a.fit_transform([METHANE])
     labels = a.get_labels()
     self.assertEqual(m.shape[2], len(labels))
     expected = (
         'C_0.0',
         'C_1.0',
         'H_0.0',
         'H_1.0',
     )
     self.assertEqual(labels, expected)
예제 #7
0
    def test_small_to_large(self):
        a = LocalEncodedBond()
        a.fit([METHANE])

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.016125813269,  # mean
            0.065471987297,  # std
            0.,              # min
            0.398807098298,  # max
            29.02646388512,  # sum
        ])
        try:
            m = a.transform([MID])
            val = numpy.array([
                m.mean(),
                m.std(),
                m.min(),
                m.max(),
                m.sum(),
            ])
            numpy.testing.assert_allclose(val, expected_results)
        except AssertionError as e:
            self.fail(e)
예제 #8
0
파일: test_atom.py 프로젝트: zizai/molml
    def test_small_to_large(self):
        a = LocalEncodedBond()
        a.fit([METHANE])

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.016125813269,  # mean
            0.065471987297,  # std
            0.,  # min
            0.398807098298,  # max
            29.02646388512,  # sum
        ])
        try:
            m = a.transform([MID])
            val = numpy.array([
                m.mean(),
                m.std(),
                m.min(),
                m.max(),
                m.sum(),
            ])
            numpy.testing.assert_allclose(val, expected_results)
        except AssertionError as e:
            self.fail(e)
예제 #9
0
 def test_fit(self):
     a = LocalEncodedBond()
     a.fit(ALL_DATA)
     self.assertEqual(a._elements, set(['N', 'C', 'O', 'H']))
예제 #10
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_form(self):
     a = LocalEncodedBond(form=0)
     m = a.fit_transform([METHANE])
     self.assertEqual(m.shape, (1, 5, 100))
예제 #11
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_add_unknown(self):
     a = LocalEncodedBond(add_unknown=True)
     a.fit([METHANE])
     m = a.transform([MID])
     self.assertEqual(m.shape, (1, 9, 300))
예제 #12
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_transform_invalid_spacing(self):
     a = LocalEncodedBond(spacing='not real"')
     with self.assertRaises(KeyError):
         a.fit_transform(ALL_DATA)
예제 #13
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_transform_before_fit(self):
     a = LocalEncodedBond()
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)
예제 #14
0
 def test_transform_before_fit(self):
     a = LocalEncodedBond()
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)
예제 #15
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_fit(self):
     a = LocalEncodedBond()
     a.fit(ALL_DATA)
     self.assertEqual(a._elements, (('C', ), ('H', ), ('N', ), ('O', )))
예제 #16
0
 def test_fit(self):
     a = LocalEncodedBond()
     a.fit(ALL_DATA)
     self.assertEqual(a._elements, ('C', 'H', 'N', 'O'))
예제 #17
0
 def test_form(self):
     a = LocalEncodedBond(form=0)
     m = a.fit_transform([METHANE])
     self.assertEqual(m.shape, (1, 5, 100))
예제 #18
0
 def test_add_unknown(self):
     a = LocalEncodedBond(add_unknown=True)
     a.fit([METHANE])
     m = a.transform([MID])
     self.assertEqual(m.shape, (1, 9, 300))
예제 #19
0
 def test_transform_invalid_spacing(self):
     a = LocalEncodedBond(spacing='not real"')
     with self.assertRaises(KeyError):
         a.fit_transform(ALL_DATA)