Esempio n. 1
0
 def test_transform(self):
     a = BagOfBonds()
     a.fit([METHANE])
     expected_results = numpy.array([[
         5.49462885, 5.49459021, 5.4945, 5.49031286, 0.56071947, 0.56071752,
         0.56071656, 0.56064089, 0.56064037, 0.56063783
     ]])
     try:
         numpy.testing.assert_array_almost_equal(a.transform([METHANE]),
                                                 expected_results)
     except AssertionError as e:
         self.fail(e)
Esempio n. 2
0
    def test_large_to_small_transform(self):
        a = BagOfBonds()
        a.fit([BIG])

        expected_results = numpy.array([[0.0] * 300 + [
            5.494628848219048, 5.494590213211275, 5.494499999706413,
            5.49031286145183
        ] + [0.0] * 596 + [
            0.5607194714171738, 0.5607175240809282, 0.5607165613824526,
            0.5606408892793993, 0.5606403708987712, 0.560637829974531
        ] + [0.0] * 270])
        try:
            numpy.testing.assert_array_almost_equal(a.transform([METHANE]),
                                                    expected_results)
        except AssertionError as e:
            self.fail(e)
Esempio n. 3
0
 def test_transform_before_fit(self):
     a = BagOfBonds()
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)
Esempio n. 4
0
 def test_small_to_large_transform_drop_values(self):
     a = BagOfBonds(drop_values=True)
     a.fit([METHANE])
     self.assertEqual(a.transform(ALL_DATA).shape, (3, 10))
Esempio n. 5
0
 def test_small_to_large_transform(self):
     a = BagOfBonds()
     a.fit([METHANE])
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)