def test_fit_atom_coordination(self): a = Connectivity(depth=1, use_coordination=True) a.fit(ALL_DATA) self.assertEqual( a._base_chains, set([('C1', ), ('N3', ), ('N2', ), ('O2', ), ('N1', ), ('O1', ), ('C4', ), ('H0', ), ('H1', ), ('O0', ), ('C3', ), ('C2', )]))
def test_fit_bond(self): a = Connectivity(depth=2) a.fit(ALL_DATA) self.assertEqual( a._base_chains, set([('H', 'O'), ('C', 'H'), ('H', 'N'), ('C', 'C'), ('H', 'H'), ('O', 'O'), ('C', 'N'), ('C', 'O')]))
def test_fit_atom_bond(self): # This should be the exact same thing as doing it with # use_bond_order=False a = Connectivity(depth=1, use_bond_order=True) a.fit(ALL_DATA) self.assertEqual(a._base_chains, set([('N', ), ('C', ), ('O', ), ('H', )]))
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())
def test_fit_angle(self): a = Connectivity(depth=3) a.fit(ALL_DATA) self.assertEqual(a._base_groups, (('C', 'C', 'C'), ('C', 'C', 'H'), ('C', 'C', 'N'), ('C', 'C', 'O'), ('C', 'N', 'C'), ('C', 'N', 'H'), ('C', 'O', 'C'), ('C', 'O', 'H'), ('H', 'C', 'H'), ('H', 'C', 'N'), ('H', 'C', 'O'), ('H', 'N', 'H'), ('N', 'C', 'N'), ('N', 'C', 'O')))
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)
def test_fit_bond_bond(self): a = Connectivity(depth=2, use_bond_order=True) a.fit(ALL_DATA) self.assertEqual( a._base_groups, ((('C', 'C', '1'), ), (('C', 'C', '2'), ), (('C', 'C', '3'), ), (('C', 'C', 'Ar'), ), (('C', 'H', '1'), ), (('C', 'N', '2'), ), (('C', 'N', '3'), ), (('C', 'N', 'Ar'), ), (('C', 'O', '1'), ), (('C', 'O', 'Ar'), ), (('H', 'H', '1'), ), (('H', 'N', '1'), ), (('H', 'O', '1'), ), (('O', 'O', '1'), )))
def test_fit_dihedral(self): # This is to test the double order flipping (CCCH vs HCCC) a = Connectivity(depth=4) a.fit(ALL_DATA) self.assertEqual( a._base_groups, (('C', 'C', 'C', 'C'), ('C', 'C', 'C', 'H'), ('C', 'C', 'C', 'N'), ('C', 'C', 'C', 'O'), ('C', 'C', 'N', 'C'), ('C', 'C', 'N', 'H'), ('C', 'C', 'O', 'C'), ('C', 'C', 'O', 'H'), ('H', 'C', 'C', 'H'), ('H', 'C', 'C', 'N'), ('H', 'C', 'C', 'O'), ('H', 'C', 'N', 'C'), ('H', 'C', 'O', 'C'), ('N', 'C', 'C', 'O'), ('N', 'C', 'N', 'C'), ('N', 'C', 'N', 'H'), ('N', 'C', 'O', 'H'), ('O', 'C', 'N', 'C')))
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())
def test_fit_atom(self): a = Connectivity(depth=1) a.fit(ALL_DATA) self.assertEqual(a._base_chains, set([('N', ), ('C', ), ('O', ), ('H', )]))
def test_large_to_small_transform(self): a = Connectivity() a.fit([BIG]) self.assertTrue((a.transform(ALL_DATA) == ALL_ATOM).all())
def test_small_to_large_transform(self): a = Connectivity() a.fit([METHANE]) self.assertTrue((a.transform(ALL_DATA) == ALL_ATOM[:, :2]).all())
def test_transform(self): a = Connectivity() a.fit(ALL_DATA) self.assertTrue((a.transform(ALL_DATA) == ALL_ATOM).all())
def test_fit_atom(self): a = Connectivity(depth=1) a.fit(ALL_DATA) self.assertEqual(a._base_groups, (('C',), ('H',), ('N',), ('O',)))