Skip to content

Commit f800986

Browse files
committed
single-linkage test less prone to alg. changes.
1 parent 6d8beff commit f800986

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,20 @@ def setUp(self):
7676
def testSingleLinkage(self):
7777
"Basic Hierarchical Clustering test with integers"
7878
cl = HierarchicalClustering(self.__data, lambda x, y: abs(x - y))
79-
cl.cluster()
79+
result = cl.getlevel(40)
80+
81+
# sort the values to make the tests less prone to algorithm changes
82+
result = sorted([sorted(_) for _ in result])
8083
self.assertEqual([
8184
[24],
8285
[84, 124, 131, 134],
8386
[336, 365, 365, 391, 398],
87+
[518, 542, 564, 594],
8488
[676],
85-
[594, 518, 542, 564],
86-
[940, 956, 971],
8789
[791],
8890
[835],
89-
], cl.getlevel(40))
91+
[940, 956, 971],
92+
], result)
9093

9194
def testCompleteLinkage(self):
9295
"Basic Hierarchical Clustering test with integers"

0 commit comments

Comments
 (0)