def test_output_oneline(self): """Ensure that main writes output: oneline""" tmpdir = tempfile.mkdtemp(prefix='dynbench-', dir=TMPDIR) try: M = bm.main(argv=[ bm.__file__, self.model_name, tmpdir + '/output-1', # outdir '--comm-format=oneline', '--graph-format=tedgelist', ]) # 102 files written: 101 from communities and 1 for graph. assert_equal( len(os.listdir(tmpdir)), 102, "102 files should be written (%s actual)" % len(os.listdir(tmpdir))) comms = M.comms(2) for line in open(tmpdir + '/output-1.t00002.comms'): if line.startswith('# label: '): c = line[9:] if line.startswith("#"): continue nodes = line.split() for n in nodes: assert int(n) in comms[int(c)] finally: shutil.rmtree(tmpdir)
def test_output_bynode(self): """Ensure that main writes output: bynode""" tmpdir = tempfile.mkdtemp(prefix='dynbench-', dir=TMPDIR) try: M = bm.main(argv=[bm.__file__, self.model_name, tmpdir+'/output-1', # outdir '--comm-format=bynode', '--graph-format=edgelist', ]) assert_equal(len(os.listdir(tmpdir)), 202, "202 files should be written (%s actual)"%len(os.listdir(tmpdir))) comms = M.comms(2) for line in open(tmpdir+'/output-1.t00002.comms'): if line.startswith("#"): continue n, c = line.split() assert int(n) in comms[int(c)] finally: shutil.rmtree(tmpdir)
def test_output_bynode(self): """Ensure that main writes output: bynode""" tmpdir = tempfile.mkdtemp(prefix='dynbench-', dir=TMPDIR) try: M = bm.main(argv=[ bm.__file__, self.model_name, tmpdir + '/output-1', # outdir '--comm-format=bynode', '--graph-format=edgelist', ]) assert_equal( len(os.listdir(tmpdir)), 202, "202 files should be written (%s actual)" % len(os.listdir(tmpdir))) comms = M.comms(2) for line in open(tmpdir + '/output-1.t00002.comms'): if line.startswith("#"): continue n, c = line.split() assert int(n) in comms[int(c)] finally: shutil.rmtree(tmpdir)
def test_output_oneline(self): """Ensure that main writes output: oneline""" tmpdir = tempfile.mkdtemp(prefix='dynbench-', dir=TMPDIR) try: M = bm.main(argv=[bm.__file__, self.model_name, tmpdir+'/output-1', # outdir '--comm-format=oneline', '--graph-format=tedgelist', ]) # 102 files written: 101 from communities and 1 for graph. assert_equal(len(os.listdir(tmpdir)), 102, "102 files should be written (%s actual)"%len(os.listdir(tmpdir))) comms = M.comms(2) for line in open(tmpdir+'/output-1.t00002.comms'): if line.startswith('# label: '): c = line[9:] if line.startswith("#"): continue nodes = line.split() for n in nodes: assert int(n) in comms[int(c)] finally: shutil.rmtree(tmpdir)