Beispiel #1
0
 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)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
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)
Beispiel #8
0
    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)
Beispiel #9
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)
Beispiel #10
0
    def test_spacing_invalid(self):
        a = EncodedBond(spacing="not valid")

        with self.assertRaises(KeyError):
            a.fit_transform([METHANE])
Beispiel #11
0
    def test_smoothing_function_error(self):
        a = EncodedBond(smoothing="not valid")

        with self.assertRaises(KeyError):
            a.fit_transform([METHANE])