def test_graph_nodes_with_duplicate_key_in_lfl_and_derived(self): # Test that LFL nodes are used in place of Derived where available. # Tests a few of the colours class One(DerivedParameterNode): # Hack to allow objects rather than classes to be added to the tree. __base__ = DerivedParameterNode __bases__ = [__base__] def derive(self, dep=P('DepOne')): pass class Four(DerivedParameterNode): # Hack to allow objects rather than classes to be added to the tree. __base__ = DerivedParameterNode __bases__ = [__base__] def derive(self, dep=P('DepFour')): pass one = One('overridden') four = Four('used') mgr1 = NodeManager({'Start Datetime': datetime.now()}, 10, [1, 2], [2, 4], [], {1:one, 4:four},{}, {}) gr = graph_nodes(mgr1) self.assertEqual(len(gr), 5) # LFL self.assertEqual(gr.edges(1), []) # as it's in LFL, it shouldn't have any edges self.assertEqual(gr.node[1], {'color': '#72f4eb', 'node_type': 'HDFNode'}) # Derived self.assertEqual(gr.edges(4), [(4,'DepFour')]) self.assertEqual(gr.node[4], {'color': '#72cdf4', 'node_type': 'DerivedParameterNode'}) # Root from analysis_engine.dependency_graph import draw_graph draw_graph(gr, 'test_graph_nodes_with_duplicate_key_in_lfl_and_derived') self.assertEqual(gr.successors('root'), [2,4]) # only the two requested are linked self.assertEqual(gr.node['root'], {'color': '#ffffff'})
def test_graph_nodes_with_duplicate_key_in_lfl_and_derived(self): """ Test that LFL nodes are used in place of Derived where available. Tests a few of the colours """ class One(DerivedParameterNode): # Hack to allow objects rather than classes to be added to the tree. __base__ = DerivedParameterNode __bases__ = [__base__] def derive(self, dep=P('DepOne')): pass class Four(DerivedParameterNode): # Hack to allow objects rather than classes to be added to the tree. __base__ = DerivedParameterNode __bases__ = [__base__] def derive(self, dep=P('DepFour')): pass one = One('overridden') four = Four('used') mgr1 = NodeManager({'Start Datetime': datetime.now()}, 10, [1, 2], [2, 4], [], {1:one, 4:four},{}, {}) gr = graph_nodes(mgr1) self.assertEqual(len(gr), 5) # LFL self.assertEqual(gr.edges(1), []) # as it's in LFL, it shouldn't have any edges self.assertEqual(gr.node[1], {'color': '#72f4eb', 'node_type': 'HDFNode'}) # Derived self.assertEqual(gr.edges(4), [(4,'DepFour')]) self.assertEqual(gr.node[4], {'color': '#72cdf4', 'node_type': 'DerivedParameterNode'}) # Root from analysis_engine.dependency_graph import draw_graph draw_graph(gr, 'test_graph_nodes_with_duplicate_key_in_lfl_and_derived') self.assertEqual(gr.successors('root'), [2,4]) # only the two requested are linked self.assertEqual(gr.node['root'], {'color': '#ffffff'})
def test_graph_nodes_with_duplicate_key_in_lfl_and_derived(self): """ Test that LFL nodes are used in place of Derived where available. Tests a few of the colours """ class One(DerivedParameterNode): # Hack to allow objects rather than classes to be added to the tree. __base__ = DerivedParameterNode __bases__ = [__base__] def derive(self, dep=P("DepOne")): pass class Four(DerivedParameterNode): # Hack to allow objects rather than classes to be added to the tree. __base__ = DerivedParameterNode __bases__ = [__base__] def derive(self, dep=P("DepFour")): pass one = One("overridden") four = Four("used") mgr1 = NodeManager({"Start Datetime": datetime.now()}, 10, [1, 2], [2, 4], [], {1: one, 4: four}, {}, {}) gr = graph_nodes(mgr1) self.assertEqual(len(gr), 5) # LFL self.assertEqual(gr.edges(1), []) # as it's in LFL, it shouldn't have any edges self.assertEqual(gr.node[1], {"color": "#72f4eb", "node_type": "HDFNode"}) # Derived self.assertEqual(gr.edges(4), [(4, "DepFour")]) self.assertEqual(gr.node[4], {"color": "#72cdf4", "node_type": "DerivedParameterNode"}) # Root from analysis_engine.dependency_graph import draw_graph draw_graph(gr, "test_graph_nodes_with_duplicate_key_in_lfl_and_derived") self.assertEqual(gr.successors("root"), [2, 4]) # only the two requested are linked self.assertEqual(gr.node["root"], {"color": "#ffffff"})