Skip to content

Commit

Permalink
Added test for non-integer node functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
MSeal committed Apr 30, 2017
1 parent 09cba5f commit a603743
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/hac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ def test_forced_clusters(self):
for elem in fc:
self.assertIn(elem, match_cluster)

def test_non_integer_clustering(self):
graph = nx.Graph();
graph.add_nodes_from(map(lambda i: chr(i), range(10)))
graph.add_edges_from([['a', 'b'], ['b', 'c'], ['a', 'c']])
dendrogram = GreedyAgglomerativeClusterer().cluster(graph)

clusters = dendrogram.clusters()
self.assertIn(set(['a', 'b', 'c']), clusters)
for node_index in range(3, 10):
self.assertIn(set([chr(node_index)]), clusters)

def test_clusterer_pickling(self):
clusterer = GreedyAgglomerativeClusterer()
p_clusterer = pickle.loads(pickle.dumps(clusterer))
Expand Down

0 comments on commit a603743

Please sign in to comment.