Skip to content

Commit

Permalink
fix: fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ntamas committed Nov 17, 2023
1 parent 675059e commit 90edc0a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/test_isomorphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ def testGetSubisomorphismsLAD(self):

# Corner cases
empty = Graph()
self.assertEqual([], g.get_subisomorphisms_lad(empty))
self.assertEqual([], empty.get_subisomorphisms_lad(empty))
self.assertEqual([[]], g.get_subisomorphisms_lad(empty))
self.assertEqual([[]], empty.get_subisomorphisms_lad(empty))

def testSubisomorphicVF2(self):
g = Graph.Lattice([3, 3], circular=False)
Expand Down
18 changes: 14 additions & 4 deletions tests/test_structural.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ def testKnn(self):
self.assertTrue(knn == [9.0] * 10)
self.assertAlmostEqual(knnk[8], 9.0, places=6)

# knn works for simple graphs only -- self.g is not simple
self.assertRaises(InternalError, self.g.knn)

# Okay, simplify it and then go on
g = self.g.copy()
g.simplify()

Expand All @@ -158,6 +154,20 @@ def testKnn(self):
self.assertAlmostEqual(knnk[1], 3, places=6)
self.assertAlmostEqual(knnk[2], 7 / 3.0, places=6)

def testKnnNonSimple(self):
knn, knnk = self.gfull.knn()
self.assertTrue(knn == [9.0] * 10)
self.assertAlmostEqual(knnk[8], 9.0, places=6)

# knn works for non-simple graphs as well
knn, knnk = self.g.knn()
diff = max(abs(a - b) for a, b in zip(knn, [17 / 5.0, 3, 4, 4]))
self.assertAlmostEqual(diff, 0.0, places=6)
self.assertEqual(len(knnk), 5)
self.assertAlmostEqual(knnk[1], 4, places=6)
self.assertAlmostEqual(knnk[2], 3, places=6)
self.assertAlmostEqual(knnk[4], 3.4, places=6)

def testDegree(self):
self.assertTrue(self.gfull.degree() == [9] * 10)
self.assertTrue(self.gempty.degree() == [0] * 10)
Expand Down

0 comments on commit 90edc0a

Please sign in to comment.