예제 #1
0
 def test_difference(self):
     sys.stdout.write("Testing set difference\n")
     fileout = os.path.join(current_dir, 'pyntacletests/test_sets/tmp/result_set.adjm')
     expected = os.path.join(current_dir, 'pyntacletests/test_sets/output/set/result_difference.adjm')
     output_graph = GraphSetOps.difference(self.graph1, self.graph2, new_graph_name='result_set')
     PyntacleExporter.AdjacencyMatrix(graph=output_graph, file=os.path.join(current_dir, 'pyntacletests/test_sets/tmp/result_set.adjm'),
                                      sep='\t', header=True)
     self.assertEqual(getmd5(fileout), getmd5(expected), 'Wrong checksum for Set, difference case')
    def test_leading_eigenvector(self):
        sys.stdout.write("Testing leading-eigenvector community finder\n")
        self.Args.which = 'leading-eigenvector'
        self.Args.output_file = 'leading-eigenvector'
        comm = communities_command(self.Args)
        with self.assertRaises(SystemExit) as cm:
            comm.run()
        the_exception = cm.exception
        self.assertEqual(the_exception.code, 0)
        files_out = sorted(glob.glob(os.path.join(current_dir, "pyntacletests/test_sets/tmp/leading-eigenvector*")))
        expected_files = sorted(glob.glob(os.path.join(current_dir, 'pyntacletests/test_sets/output/communities/leading-eigenvector/leading-*')))

        for f, e in zip(files_out, expected_files):
            self.assertEqual(getmd5(f), getmd5(e), 'Wrong checksum for communities, leading-eigenvector case')
예제 #3
0
 def test_random(self):
     sys.stdout.write("Testing random generator\n")
     self.Args.which = 'random'
     self.Args.edges = None
     self.Args.nodes = None
     self.Args.probability = None
     self.Args.output_file = 'random'
     gen = generate_command(self.Args)
     with self.assertRaises(SystemExit) as cm:
         gen.run()
     the_exception = cm.exception
     self.assertEqual(the_exception.code, 0)
     fileout = os.path.join(current_dir,
                            'pyntacletests/test_sets/tmp/random.adjm')
     expected = os.path.join(
         current_dir,
         'pyntacletests/test_sets/output/generate/random/random.adjm')
     self.assertEqual(getmd5(fileout), getmd5(expected),
                      'Wrong checksum for PyntacleGenerator, random case')
예제 #4
0
    def test_tree(self):
        sys.stdout.write("Testing tree generator\n")
        self.Args.which = 'tree'
        self.Args.output_file = 'tree'
        self.Args.nodes = None
        self.Args.children = None

        gen = generate_command(self.Args)
        with self.assertRaises(SystemExit) as cm:
            gen.run()
        the_exception = cm.exception
        self.assertEqual(the_exception.code, 0)
        fileout = os.path.join(current_dir,
                               'pyntacletests/test_sets/tmp/tree.adjm')
        expected = os.path.join(
            current_dir,
            'pyntacletests/test_sets/output/generate/tree/tree.adjm')
        self.assertEqual(getmd5(fileout), getmd5(expected),
                         'Wrong checksum for PyntacleGenerator, tree case')
예제 #5
0
    def test_smallworld(self):
        sys.stdout.write("Testing smallworld generator\n")
        self.Args.which = 'small-world'
        self.Args.output_file = 'smallworld'
        self.Args.nodes = None
        self.Args.lattice = 2
        self.Args.lattice_size = None
        self.Args.nei = None
        self.Args.probability = 0.5

        gen = generate_command(self.Args)
        with self.assertRaises(SystemExit) as cm:
            gen.run()
        the_exception = cm.exception
        self.assertEqual(the_exception.code, 0)
        fileout = os.path.join(current_dir,
                               'pyntacletests/test_sets/tmp/smallworld.adjm')
        expected = os.path.join(
            current_dir,
            'pyntacletests/test_sets/output/generate/smallworld/smallworld.adjm'
        )
        self.assertEqual(
            getmd5(fileout), getmd5(expected),
            'Wrong checksum for PyntacleGenerator, smallworld case')