当前位置: 首页>>代码示例>>Python>>正文


Python dependency_graph.DependencyGraph类代码示例

本文整理汇总了Python中vunit.dependency_graph.DependencyGraph的典型用法代码示例。如果您正苦于以下问题:Python DependencyGraph类的具体用法?Python DependencyGraph怎么用?Python DependencyGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DependencyGraph类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_dependent

 def test_get_dependent(self):
     nodes = ['a', 'b', 'c', 'd', 'e']
     dependencies = [('a', 'b'), ('b', 'c'), ('c', 'd'), ('e', 'd')]
     graph = DependencyGraph()
     self._add_nodes_and_dependencies(graph, nodes, dependencies)
     self.assertEqual(graph.get_dependent(set('a')), set(('a', 'b', 'c', 'd')))
     self.assertEqual(graph.get_dependent(set('e')), set(('d', 'e')))
开发者ID:barri,项目名称:vunit,代码行数:7,代码来源:test_dependency_graph.py

示例2: test_should_sort_in_topological_order_when_there_are_dependencies

 def test_should_sort_in_topological_order_when_there_are_dependencies(self):
     nodes = ["a", "b", "c", "d", "e", "f"]
     dependencies = [("a", "b"), ("a", "c"), ("b", "d"), ("e", "f")]
     graph = DependencyGraph()
     self._add_nodes_and_dependencies(graph, nodes, dependencies)
     result = graph.toposort()
     self._check_result(result, dependencies)
开发者ID:mark-newsam,项目名称:vunit,代码行数:7,代码来源:test_dependency_graph.py

示例3: test_get_direct_dependencies_should_return_empty_set_when_no_dependendencies

 def test_get_direct_dependencies_should_return_empty_set_when_no_dependendencies(self):
     nodes = ['a', 'b', 'c']
     dependencies = []
     graph = DependencyGraph()
     self._add_nodes_and_dependencies(graph, nodes, dependencies)
     result = graph.get_direct_dependencies('b')
     self.assertTrue(isinstance(result, (set)))
     self.assertFalse(result)
开发者ID:varunnagpaal,项目名称:vunit,代码行数:8,代码来源:test_dependency_graph.py

示例4: test_get_direct_dependencies_should_return_dependendencies_set

 def test_get_direct_dependencies_should_return_dependendencies_set(self):
     nodes = ['a', 'b', 'c', 'd']
     dependencies = [('a', 'b'), ('a', 'c')]
     graph = DependencyGraph()
     self._add_nodes_and_dependencies(graph, nodes, dependencies)
     result = graph.get_direct_dependencies('c')
     self.assertFalse('b' in result)
     self.assertTrue('a' in result)
开发者ID:varunnagpaal,项目名称:vunit,代码行数:8,代码来源:test_dependency_graph.py

示例5: test_should_sort_in_topological_order_when_there_are_dependencies

 def test_should_sort_in_topological_order_when_there_are_dependencies(self):
     nodes = ['a', 'b', 'c', 'd', 'e', 'f']
     dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('e', 'f')]
     g = DependencyGraph()
     self._add_nodes_and_dependencies(g, nodes, dependencies)
     result = g.toposort()
     for d in dependencies:
         self.assertTrue(result.index(d[0]) < result.index(d[1]), "%s is not before %s" % d)
开发者ID:tomasnilefrost,项目名称:vunit,代码行数:8,代码来源:test_dependency_graph.py

示例6: test_should_raise_runtime_error_exception_on_long_circular_dependency

    def test_should_raise_runtime_error_exception_on_long_circular_dependency(self):
        nodes = ['a', 'b', 'c', 'd']
        dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('d', 'a')]
        graph = DependencyGraph()
        self._add_nodes_and_dependencies(graph, nodes, dependencies)

        try:
            graph.toposort()
        except CircularDependencyException as exc:
            self.assertEqual(exc.path, ['a', 'b', 'd', 'a'])
        else:
            self.fail("Exception not raised")
开发者ID:barri,项目名称:vunit,代码行数:12,代码来源:test_dependency_graph.py

示例7: test_get_dependencies_detects_circular_dependencies

    def test_get_dependencies_detects_circular_dependencies(self):
        nodes = ["a", "b", "c"]
        dependencies = [("b", "a"), ("c", "b"), ("a", "c")]
        graph = DependencyGraph()
        self._add_nodes_and_dependencies(graph, nodes, dependencies)

        try:
            graph.get_dependencies(set("a"))
        except CircularDependencyException as exc:
            self.assertEqual(exc.path, ["a", "b", "c", "a"])
        else:
            self.fail("Exception not raised")
开发者ID:mark-newsam,项目名称:vunit,代码行数:12,代码来源:test_dependency_graph.py

示例8: _create_dependency_graph

    def _create_dependency_graph(self):
        """
        Create a DependencyGraph object of the HDL code project
        """
        def add_dependency(start, end):
            """
            Utility to add dependency
            """
            if start.name == end.name:
                return

            is_new = dependency_graph.add_dependency(start, end)

            if is_new:
                LOGGER.info('Adding dependency: %s depends on %s', end.name, start.name)

        def add_dependencies(dependency_function, files):
            """
            Utility to add all dependencies returned by a dependency_function
            returning an iterator of dependencies
            """
            for source_file in files:
                for dependency in dependency_function(source_file):
                    add_dependency(dependency, source_file)

        dependency_graph = DependencyGraph()
        for source_file in self.get_source_files_in_order():
            dependency_graph.add_node(source_file)

        vhdl_files = [source_file
                      for source_file in self.get_source_files_in_order()
                      if source_file.file_type == 'vhdl']
        add_dependencies(self._find_other_design_unit_dependencies, vhdl_files)
        add_dependencies(self._find_primary_secondary_design_unit_dependencies, vhdl_files)

        verilog_files = [source_file
                         for source_file in self.get_source_files_in_order()
                         if source_file.file_type == 'verilog']

        add_dependencies(self._find_verilog_package_dependencies, verilog_files)
        add_dependencies(self._find_verilog_module_dependencies, verilog_files)

        if self._depend_on_components:
            add_dependencies(self._find_component_design_unit_dependencies, vhdl_files)

        return dependency_graph
开发者ID:enzochiau,项目名称:vunit,代码行数:46,代码来源:project.py

示例9: test_should_resort_after_additions

 def test_should_resort_after_additions(self):
     nodes = ["a", "b", "c", "d", "e", "f"]
     dependencies = [("a", "b"), ("a", "c"), ("b", "d"), ("e", "f")]
     graph = DependencyGraph()
     self._add_nodes_and_dependencies(graph, nodes, dependencies)
     graph.toposort()
     dependencies = [("a", "b"), ("a", "c"), ("b", "d"), ("e", "f"), ("b", "g")]
     graph.add_node("g")
     graph.add_dependency("b", "g")
     result = graph.toposort()
     self._check_result(result, dependencies)
开发者ID:mark-newsam,项目名称:vunit,代码行数:11,代码来源:test_dependency_graph.py

示例10: test_should_resort_after_additions

 def test_should_resort_after_additions(self):
     nodes = ['a', 'b', 'c', 'd', 'e', 'f']
     dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('e', 'f')]
     g = DependencyGraph()
     self._add_nodes_and_dependencies(g, nodes, dependencies)
     g.toposort()
     dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('e', 'f'), ('b', 'g')]
     g.add_node('g')
     g.add_dependency('b', 'g')
     result = g.toposort()
     for d in dependencies:
         self.assertTrue(result.index(d[0]) < result.index(d[1]), "%s is not before %s" % d)
开发者ID:tomasnilefrost,项目名称:vunit,代码行数:12,代码来源:test_dependency_graph.py

示例11: test_should_return_empty_compile_order_for_no_nodes

 def test_should_return_empty_compile_order_for_no_nodes(self):
     graph = DependencyGraph()
     self.assertEqual(graph.toposort(), [], 'Should return empty list')
开发者ID:varunnagpaal,项目名称:vunit,代码行数:3,代码来源:test_dependency_graph.py

示例12: test_should_return_list_of_nodes_when_there_are_no_dependencies

 def test_should_return_list_of_nodes_when_there_are_no_dependencies(self):
     nodes = ['a', 'b', 'c', 'd']
     graph = DependencyGraph()
     self._add_nodes_and_dependencies(graph, nodes, [])
     result = graph.toposort()
     self.assertEqual(result.sort(), nodes.sort(), 'Should return the node list in any order')
开发者ID:varunnagpaal,项目名称:vunit,代码行数:6,代码来源:test_dependency_graph.py


注:本文中的vunit.dependency_graph.DependencyGraph类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。