test: add test of case self_connection=False
@@ -26,7 +26,6 @@ class TestGetAtomicNumbers(object):
expect = numpy.array([6, 7, 6, 8, 0], dtype=numpy.int32)
numpy.testing.assert_equal(actual, expect)
-
def test_normal_truncated(self, sample_molecule):
with pytest.raises(ValueError):
adj = common.construct_atomic_number_array(sample_molecule, 3)
@@ -54,6 +53,22 @@ class TestGetAdjMatrix(object):
dtype=numpy.float32)
numpy.testing.assert_equal(adj, expect)
+ def test_normal_no_self_connection(self, sample_molecule_2):
+ adj = common.construct_adj_matrix(sample_molecule_2,
+ self_connection=False)
+
+ assert adj.shape == (7, 7)
+ expect = numpy.array(
+ [[0., 1., 0., 0., 0., 0., 0.],
+ [1., 0., 1., 0., 0., 0., 1.],
+ [0., 1., 0., 1., 0., 0., 0.],
+ [0., 0., 1., 0., 1., 0., 0.],
+ [0., 0., 0., 1., 0., 1., 0.],
+ [0., 0., 0., 0., 1., 0., 1.],
+ [0., 1., 0., 0., 0., 1., 0.]],
+ dtype=numpy.float32)
+ numpy.testing.assert_equal(adj, expect)
+
def test_normal_padding(self, sample_molecule_2):
adj = common.construct_adj_matrix(sample_molecule_2, 8)
@@ -74,3 +89,5 @@ class TestGetAdjMatrix(object):
with pytest.raises(ValueError):
adj = common.construct_adj_matrix(sample_molecule_2, 6)
+if __name__ == '__main__':
+ pytest.main([__file__, '-v', '-s'])
