def test_allow_top(self): """Top is allowed by default""" s = dl.lib.StateSaver() with dl.DeltaGraph() as graph: s.save_and_exit(return_1_const()) self.assertTrue(graph.check())
def test_top_serialisation(self): """If a port has type top serialisation should throw an error.""" s = StateSaver() with DeltaGraph() as graph: s.save_and_exit(return_1_const()) with self.assertRaises(DeltaTypeError): serialise_graph(graph)
def test_splitting_const_non_const(self): """Const -> non-const -> exit.""" s = dl.lib.StateSaver(int, verbose=True) with dl.DeltaGraph() as graph: val = return_1_const() s.save_and_exit(add_non_const(val, val)) self.check_executes_graph(graph, "saving 2\n")
def test_splitting_const_const(self): """Const -> const -> exit.""" s = dl.lib.StateSaver(int, verbose=True) with dl.DeltaGraph() as graph: val = return_1_const() out = add_non_const(increment_const(val), increment_const(val)) s.save_and_exit(out) self.check_executes_graph(graph, "saving 4\n")
def test_const_node(self): """Constant node has one output reused multiple times.""" with dl.DeltaGraph() as graph: output = return_1_const() terminate_non_const(output) terminate_non_const(output) terminate_non_const(output) self.assertTrue(graph.check()) self.assertEqual(len(graph.nodes), 5) self.assertEqual(type(graph.find_node_by_name("return_1_const").body), dl.wiring.PyConstBody) self.assertEqual(type(graph.find_node_by_name("splitter").body), dl.wiring.PyConstBody)
def setUp(self): """Set up a simple graph""" saver = StateSaver(int) with DeltaGraph() as test_graph: saver.save_and_exit(return_1_const()) self.graph = test_graph