Exemplo n.º 1
0
 def test_unknown(self):
     a = Connectivity(add_unknown=True)
     expected_results = numpy.array([[1,  4, 0],
                                     [2,  3, 4],
                                     [25, 15, 9]])
     a.fit([METHANE])
     self.assertTrue((a.transform(ALL_DATA) == expected_results).all())
Exemplo n.º 2
0
 def test_tfidf(self):
     a = Connectivity(do_tfidf=True)
     expected = numpy.array([[0., 0., 0., 0.], [0., 0., 0., 1.62186043],
                             [0., 0., 5.49306144, 1.62186043]])
     a.fit(ALL_DATA)
     try:
         m = a.transform(ALL_DATA)
         numpy.testing.assert_array_almost_equal(m, expected)
     except AssertionError as e:
         self.fail(e)
Exemplo n.º 3
0
 def test_fit_atom_separated(self):
     a = Connectivity(depth=1)
     a.fit([METHANE2])
     self.assertEqual(a._base_chains, set([('C', ), ('H', )]))
     self.assertTrue((a.transform([METHANE2]) == numpy.array([[1,
                                                               4]])).all())
Exemplo n.º 4
0
 def test_transform_before_fit(self):
     a = Connectivity()
     with self.assertRaises(ValueError):
         a.transform(ALL_DATA)
Exemplo n.º 5
0
 def test_large_to_small_transform(self):
     a = Connectivity()
     a.fit([BIG])
     self.assertTrue((a.transform(ALL_DATA) == ALL_ATOM).all())
Exemplo n.º 6
0
 def test_small_to_large_transform(self):
     a = Connectivity()
     a.fit([METHANE])
     self.assertTrue((a.transform(ALL_DATA) == ALL_ATOM[:, :2]).all())
Exemplo n.º 7
0
 def test_transform(self):
     a = Connectivity()
     a.fit(ALL_DATA)
     self.assertTrue((a.transform(ALL_DATA) == ALL_ATOM).all())