Skip to content

Commit 83e0a05

Browse files
author
Caterina Gratton
committed
Modified test_apply_node_move to check that there aren't empty modules.
1 parent 24d59f4 commit 83e0a05

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

brainx/tests/test_modularity.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,13 @@ def test_apply_node_move():
674674
modularity of the new and old parititions"""
675675

676676
# nnod_mod, av_degrees, nmods
677-
networks = [ [3, [2], [2, 3, 4]],
678-
[4, [2, 3], [2, 4, 6]],
677+
#networks = [ [3, [2], [2, 3, 4]],
678+
# [4, [2, 3], [2, 4, 6]],
679+
# [8, [4, 6], [4, 6, 8]] ]
680+
networks = [ [4, [2, 3], [2, 4, 6]],
679681
[8, [4, 6], [4, 6, 8]] ]
680682

683+
681684
for nnod_mod, av_degrees, nmods in networks:
682685
for nmod in nmods:
683686
nnod = nnod_mod*nmod
@@ -696,12 +699,16 @@ def test_apply_node_move():
696699
#List of modules in the partition
697700
r_mod=range(len(part_rand))
698701

702+
#Make a graph_partition object
703+
graph_partition = mod.GraphPartition(g,part_rand)
704+
699705
#select two modules to change node assignments
700706
mod_per = np.random.permutation(r_mod)
701707
m1 = mod_per[0]; m2 = mod_per[1]
702-
703-
#Make a graph_partition object
704-
graph_partition = mod.GraphPartition(g,part_rand)
708+
while len(graph_partition.index[m1]) <= 1:
709+
mod_per = np.random.permutation(r_mod)
710+
m1 = mod_per[0]
711+
m2 = mod_per[1]
705712

706713
#pick a random node to move between modules m1 and m2
707714
node_list=list(graph_partition.index[m1])

0 commit comments

Comments
 (0)