Skip to content

Commit dcacb5f

Browse files
author
CindeeM
committed
TEST: added test for setter of the WeightedGraphPartition object
1 parent f6c7694 commit dcacb5f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

brainx/tests/test_weighted_modularity.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ def test_init(self):
5050
# generated communities
5151
comm = [set([node]) for node in self.graph.nodes()]
5252
self.assertEqual(part.communities, comm)
53+
# test communities cannot be replaced by garbage
54+
with self.assertRaises(TypeError):
55+
part.communities = 11
56+
# but we can pass a valid community partition
57+
part.communities = comm
58+
self.assertEqual(part.communities, comm)
5359

5460
def test_communities_degree(self):
5561
## if no community, method will raise error

brainx/weighted_modularity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def communities(self):
4444

4545
@communities.setter
4646
def communities(self, value):
47-
self._communities = self.set_communities(value)
47+
self.set_communities(value)
4848

4949
def _init_communities_from_nodes(self):
5050
""" creates a new communities with one node per community

0 commit comments

Comments
 (0)