Пример #1
0
    def setUp(self):
        Weaver(MinTree)  # Just give the reference to the RAG class
        instance = Program(Pair(Leaf(1), Pair(Leaf(2), Leaf(3))))

        Weaver.infer_parents(instance)

        # simply get all the nodes in tree after attribution, so one can get the nodes to check the result.
        self.allnodes = instance.traverse()
Пример #2
0
    def setUp(self):
        Weaver(Calc)  # Just give the reference to the RAG class
        self.instance = Program(Mul(Add(Numeral(1), Numeral(3)), Numeral(2)))

        Weaver.infer_parents(self.instance)

        # simply get all the nodes in tree after attribution, so one can get the nodes to check the result.
        self.allnodes = self.instance.traverse()
Пример #3
0
    def setUp(self):
        weaver = Weaver(RAG)

        left = Left()
        right = Right()

        self.node = Node(left, right)

        Weaver.infer_parents(self.node)
Пример #4
0
    def __init__(self):

        Weaver(Calc)  # Just give the reference to the RAG class
        instance = Program(Mul(Add(Numeral(1), Numeral(3)),
                               Numeral(2)))  # Create an instance of the tree

        Weaver.infer_parents(instance)  #Infer parents for the tree

        # simply get all the nodes in tree after attribution, so one can get the nodes to check the result.
        self.allnodes = instance.traverse()
Пример #5
0
    def setUp(self):
        weaver = Weaver(RAG)

        self.root = Root()
        self.root.set_node(Node())
        self.root.node.set_node(Node())

        Weaver.infer_parents(self.root)

        self.root.node.node.inhAttr()
Пример #6
0
    def setUp(self):
        Weaver(RAG)

        self.root = Root()
        self.root.set_node(Node())
        self.root.node.set_node(Node())

        Weaver.infer_parents(self.root)

        self.root.node.node.root()

        print(self.root.node.node.root())
        print(self.root)
Пример #7
0
    def __init__(self):

        Weaver(MinTree)  # Just give the reference to the RAG class

        self.m = StateMachine()
        self.m.add_declaration(State("S1"))
        self.m.add_declaration(State("S2"))
        self.m.add_declaration(State("S3"))

        self.m.add_declaration(Transition("a", "S1", "S2"))
        self.m.add_declaration(Transition("b", "S2", "S1"))
        self.m.add_declaration(Transition("a", "S2", "S3"))

        Weaver.infer_parents(self.m)  #Infer parents for the tree
Пример #8
0
class MinTreeTest(TestCase):
    def setUp(self):
        self.weaver = Weaver(RAG)  # Just give the reference to the RAG class
        self.instance = Program(0, Pair(1, Leaf(2), Pair(3, Leaf(4), Leaf(5))))

    def test_infer_parents(self):
        self.weaver.infer_parents(self.instance)

        pair1 = self.instance.get_children()[0]

        self.assertEqual(pair1.get_parent(), self.instance)

        leaf2 = pair1.get_children()[0]
        pair3 = pair1.get_children()[1]

        self.assertEqual(leaf2.get_parent(), pair1)
        self.assertEqual(pair3.get_parent(), pair1)

        leaf4 = pair3.get_children()[0]
        leaf5 = pair3.get_children()[1]

        self.assertEqual(leaf4.get_parent(), pair3)
        self.assertEqual(leaf5.get_parent(), pair3)
Пример #9
0
 def setUp(self):
     self.weaver = Weaver(RAG)  # Just give the reference to the RAG class
     self.instance = Program(0, Pair(1, Leaf(2), Pair(3, Leaf(4), Leaf(5))))