コード例 #1
0
 def test_fit(self):
     a = EncodedBond()
     a.fit(ALL_DATA)
     self.assertEqual(
         a._element_pairs,
         set([('H', 'O'), ('O', 'O'), ('N', 'O'), ('C', 'O'), ('C', 'H'),
              ('H', 'N'), ('H', 'H'), ('C', 'C'), ('C', 'N'), ('N', 'N')]))
コード例 #2
0
ファイル: test_molecule.py プロジェクト: aced125/molml
 def test_get_labels(self):
     a = EncodedBond(segments=2, start=0., end=1.)
     X = a.fit_transform([METHANE])
     labels = a.get_labels()
     self.assertEqual(X.shape[1], len(labels))
     expected = (
         'C-H_0.0', 'C-H_1.0',
         'H-H_0.0', 'H-H_1.0',
     )
     self.assertEqual(labels, expected)
コード例 #3
0
 def test_max_depth_neg(self):
     a = EncodedBond(max_depth=-1)
     # This is a cheap test to prevent needing all the values here
     expected_results = numpy.array([
         0.503237244954,  # mean
         0.857850829564,  # std
         0.,  # min
         7.15861023,  # max
     ])
     try:
         m = a.fit_transform([BIG])
         assert_close_statistics(m, expected_results)
     except AssertionError as e:
         self.fail(e)
コード例 #4
0
 def test_fit_transform(self):
     a = EncodedBond()
     # This is a cheap test to prevent needing all the values here
     expected_results = numpy.array([
         0.042672,  # mean
         0.246663,  # std
         0.,  # min
         2.392207,  # max
     ])
     try:
         m = a.fit_transform([METHANE])
         assert_close_statistics(m, expected_results)
     except AssertionError as e:
         self.fail(e)
コード例 #5
0
    def test_spacing_log(self):
        a = EncodedBond(spacing="log")

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.072768,  # mean
            0.318508,  # std
            0.,  # min
            2.339376,  # max
        ])
        try:
            m = a.fit_transform([METHANE])
            assert_close_statistics(m, expected_results)
        except AssertionError as e:
            self.fail(e)
コード例 #6
0
    def test_spacing_inverse(self):
        a = EncodedBond(spacing="inverse")

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.051207,  # mean
            0.269248,  # std
            0.,  # min
            2.387995,  # max
        ])
        try:
            m = a.fit_transform([METHANE])
            assert_close_statistics(m, expected_results)
        except AssertionError as e:
            self.fail(e)
コード例 #7
0
    def test_max_depth_1(self):
        a = EncodedBond(max_depth=1)

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.0443793,  # mean
            0.33766942,  # std
            0.,  # min
            5.76559336,  # max
        ])
        try:
            m = a.fit_transform([BIG])
            assert_close_statistics(m, expected_results)
        except AssertionError as e:
            self.fail(e)
コード例 #8
0
    def test_smoothing_function(self):
        a = EncodedBond(smoothing="norm_cdf")

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            3.859534e+000,  # mean
            2.182923e+000,  # std
            0.,  # min
            6.000000e+000,  # max
        ])
        try:
            m = a.fit_transform([METHANE])
            assert_close_statistics(m, expected_results)
        except AssertionError as e:
            self.fail(e)
コード例 #9
0
 def test_small_to_large_transform(self):
     a = EncodedBond()
     a.fit([METHANE])
     # This is a cheap test to prevent needing all the values here
     expected_results = numpy.array([
         9.207308e-001,  # mean
         1.062388e+000,  # std
         0.,  # min
         5.023670e+000,  # max
     ])
     try:
         m = a.transform([BIG])
         assert_close_statistics(m, expected_results)
     except AssertionError as e:
         self.fail(e)
コード例 #10
0
 def test_large_to_small_transform(self):
     a = EncodedBond()
     a.fit([MID])
     # This is a cheap test to prevent needing all the values here
     expected_results = numpy.array([
         0.014224,  # mean
         0.143824,  # std
         0.,  # min
         2.392207,  # max
     ])
     try:
         m = a.transform([METHANE])
         assert_close_statistics(m, expected_results)
     except AssertionError as e:
         self.fail(e)
コード例 #11
0
ファイル: test_molecule.py プロジェクト: alvarovm/molml
    def test_max_depth_3(self):
        a = EncodedBond(max_depth=3)

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.18434482,  # mean
            0.62589799,  # std
            0.,  # min
            7.15861023,  # max
        ])
        try:
            m = a.fit_transform([BIG])
            assert_close_statistics(m, expected_results)
        except AssertionError as e:
            self.fail(e)
コード例 #12
0
    def test_form_0(self):
        a = EncodedBond(form=0)

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.085345,  # mean
            0.343574,  # std
            0.,  # min
            2.392207,  # max
        ])
        try:
            m = a.fit_transform([METHANE])
            self.assertEqual(m.shape, (1, 100))
            assert_close_statistics(m, expected_results)
        except AssertionError as e:
            self.fail(e)
コード例 #13
0
    def test_add_unknown(self):
        a = EncodedBond(add_unknown=True)
        a.fit([METHANE])

        # This is a cheap test to prevent needing all the values here
        expected_results = numpy.array([
            0.09105,  # mean
            0.231761,  # std
            0.,  # min
            1.869012,  # max
        ])
        try:
            m = a.transform([MID])
            self.assertEqual(m.shape, (1, 300))
            assert_close_statistics(m, expected_results)
        except AssertionError as e:
            self.fail(e)
コード例 #14
0
    def test_spacing_invalid(self):
        a = EncodedBond(spacing="not valid")

        with self.assertRaises(KeyError):
            a.fit_transform([METHANE])
コード例 #15
0
    def test_smoothing_function_error(self):
        a = EncodedBond(smoothing="not valid")

        with self.assertRaises(KeyError):
            a.fit_transform([METHANE])
コード例 #16
0
 def test_transform_before_fit(self):
     a = EncodedBond()
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)