Skip to content

Commit

Permalink
⬆️ fix test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
GiulioRossetti committed Jan 30, 2020
1 parent 8a9356c commit 472ba90
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 44 deletions.
5 changes: 3 additions & 2 deletions cdlib/algorithms/overlapping_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,9 @@ def egonet_splitter(g, resolution=1.0):

# Reshaping the results
coms_to_node = defaultdict(list)
for n, c in members.items():
coms_to_node[c].append(n)
for n, cs in members.items():
for c in cs:
coms_to_node[c].append(n)

coms = [list(c) for c in coms_to_node.values()]

Expand Down
78 changes: 36 additions & 42 deletions cdlib/test/test_community_discovery_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,12 @@ def test_markov_clustering(self):
self.assertEqual(type(communities.communities[0][0]), int)

def test_bigClam(self):
if gt is not None:
g = get_string_graph()
coms = algorithms.big_clam(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), str)
g = nx.karate_club_graph()
coms = algorithms.big_clam(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), int)

def test_lemon(self):
g = get_string_graph()
Expand Down Expand Up @@ -414,49 +413,44 @@ def test_sbm_nested_dl(self):
self.assertEqual(type(coms.communities[0][0]), str)

def test_danmf(self):
if gt is not None:
g = get_string_graph()
coms = algorithms.danmf(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), str)
g = get_string_graph()
coms = algorithms.danmf(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), int)

def test_egonet_splitter(self):
if gt is not None:
g = get_string_graph()
coms = algorithms.egonet_splitter(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), str)
g = get_string_graph()
coms = algorithms.egonet_splitter(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), str)

def test_nnsed(self):
if gt is not None:
g = get_string_graph()
coms = algorithms.nnsed(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), str)
g = nx.karate_club_graph()
coms = algorithms.nnsed(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), int)

def test_nmnf(self):
if gt is not None:
g = get_string_graph()
coms = algorithms.nmnf(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), str)
g = nx.karate_club_graph()
coms = algorithms.nmnf(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), int)

def test_edmot(self):
if gt is not None:
g = get_string_graph()
coms = algorithms.edmot(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), str)
g = nx.karate_club_graph()
coms = algorithms.edmot(g)
self.assertEqual(type(coms.communities), list)
if len(coms.communities) > 0:
self.assertEqual(type(coms.communities[0]), list)
self.assertEqual(type(coms.communities[0][0]), int)

def test_bimlpa(self):
g = nx.algorithms.bipartite.random_graph(50, 50, 0.25)
Expand Down

0 comments on commit 472ba90

Please sign in to comment.