Skip to content

Commit f6c7694

Browse files
author
CindeeM
committed
RF: refactor tests after moving _combine into LouvainCommunityDetection class
1 parent c47314c commit f6c7694

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

brainx/tests/test_weighted_modularity.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,13 @@ def test_run(self):
218218
self.assertEqual(len(final_partitions), 2)
219219

220220

221-
def test_combine():
222-
first = [set([0,1,2]), set([3,4,5]), set([6,7])]
223-
second = [set([0,2]), set([1])]
224-
npt.assert_raises(ValueError, wm._combine, second, first)
225-
res = wm._combine(first, second)
226-
npt.assert_equal(res, [set([0,1,2,6,7]), set([3,4,5])])
221+
def test_combine(self):
222+
223+
first = [set([0,1,2]), set([3,4,5]), set([6,7])]
224+
second = [set([0,2]), set([1])]
225+
npt.assert_raises(ValueError, self.louvain._combine, second, first)
226+
res = self.louvain._combine(first, second)
227+
npt.assert_equal(res, [set([0,1,2,6,7]), set([3,4,5])])
227228

228229
def test_meta_graph():
229230
graph, communities = get_test_data()

brainx/weighted_modularity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,18 @@ def _move_node(part, node, new_comm):
324324
new_community = [x for x in new_community if len(x) > 0]
325325
return WeightedPartition(part.graph, new_community)
326326

327-
@staticmethod
328-
def partitions_from_dendogram(dendo):
327+
def partitions_from_dendogram(self, dendo):
329328
""" returns community partitions based on results in dendogram
330329
"""
331330
all_partitions = []
332331
init_part = dendo[0].communities
333332
all_partitions.append(init_part)
334333
for partition in dendo[1:]:
335-
init_part = _combine(init_part, partition.communities)
334+
init_part = self._combine(init_part, partition.communities)
336335
all_partitions.append(init_part)
337336
return all_partitions
338337

338+
@staticmethod
339339
def _combine(prev, next):
340340
"""combines nodes in sets (prev) based on mapping defined by
341341
(next) (which now treats a previous communitity as a node)

0 commit comments

Comments
 (0)