Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 def test_transform_before_fit(self):
     a = EncodedBond()
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)