-
Notifications
You must be signed in to change notification settings - Fork 76
/
test.py
34 lines (26 loc) · 972 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
import math
import unittest
from pylouvain import PyLouvain
class PylouvainTest(unittest.TestCase):
def test_arxiv(self):
pyl = PyLouvain.from_file("data/arxiv.txt")
partition, q = pyl.apply_method()
def test_citations(self):
pyl = PyLouvain.from_file("data/hep-th-citations")
partition, q = pyl.apply_method()
def test_karate_club(self):
pyl = PyLouvain.from_file("data/karate.txt")
partition, q = pyl.apply_method()
q_ = q * 10000
self.assertEqual(4, len(partition))
self.assertEqual(4298, math.floor(q_))
self.assertEqual(4299, math.ceil(q_))
def test_lesmis(self):
pyl = PyLouvain.from_gml_file("data/lesmis.gml")
partition, q = pyl.apply_method()
def test_polbooks(self):
pyl = PyLouvain.from_gml_file("data/polbooks.gml")
partition, q = pyl.apply_method()
if __name__ == '__main__':
unittest.main()