-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse_results.py
138 lines (105 loc) · 4.71 KB
/
parse_results.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
from conditions import Condition
from side import Side
from conditions import StateConditions
from variable import Variable
from variable import TypeVariable
from conditions import CustomConditions
from conditions import CompareCondition
a = Variable(TypeVariable.INPUT)
a2 = Variable(TypeVariable.INPUT)
a3 = Variable(TypeVariable.INPUT)
g1 = Variable(TypeVariable.OUTPUT)
g2 = Variable(TypeVariable.OUTPUT)
g3 = Variable(TypeVariable.OUTPUT)
# """ test of contradictions """
# test = Condition(Side(a), Side(), StateConditions.IS_ZERO)
# test2 = Condition(Side(a), Side(), StateConditions.IS_NOT_ZERO)
# assert test.is_contradiction(test2)
# test = Condition(Side(a, a2, g3), Side(), StateConditions.IS_ZERO)
# test2 = Condition(Side(a, a2, g3), Side(), StateConditions.IS_NOT_ZERO)
# assert test.is_contradiction(test2)
""" test of useless """
test = Condition(Side(), Side(), StateConditions.IS_ZERO)
assert test.is_useless()
test = Condition(Side(a, g3), Side(g3, a), StateConditions.IS_EQUAL)
assert test.is_useless()
test = Condition(Side(a, g3), Side(a, g3), StateConditions.IS_EQUAL)
assert test.is_useless()
test = Condition(Side(a, g3), Side(), StateConditions.IS_ZERO)
assert test.is_useless() == False
""" test of normalise """
test = Condition(Side(a, g3), Side(), StateConditions.IS_EQUAL)
test2 = Condition(Side(g3), Side(a), StateConditions.IS_EQUAL)
test.normalise()
assert test == test2
test = Condition(Side(), Side(a, g3), StateConditions.IS_EQUAL)
test2 = Condition(Side(g3), Side(a), StateConditions.IS_EQUAL)
test.normalise()
assert test == test2
""" test of swap """
test = Side(a, a3)
test2 = Side(g1, g2)
cond = Condition(test, test2, StateConditions.IS_EQUAL)
cond.swap_sides()
assert cond.get_left_side() == test2 and cond.get_right_side() == test
""" test of update"""
c = Condition(Side(a, a2, a3), Side(g1, a3), StateConditions.IS_EQUAL)
c1 = Condition(Side(a), Side(g3), StateConditions.IS_EQUAL)
c.update_with(c1)
c2 = Condition(Side(g3), Side(g1, a2), StateConditions.IS_EQUAL)
assert c == c2
c = Condition(Side(a, a2, a3), Side(a, g3), StateConditions.IS_EQUAL)
c1 = Condition(Side(a), Side(a2, a3), StateConditions.IS_EQUAL)
c2 = Condition(Side(g3), Side(a2, a3), StateConditions.IS_EQUAL)
c.update_with(c1)
assert c == c2
c = Condition(Side(a, a2, a3, g3), Side(), StateConditions.IS_NOT_ZERO)
c1 = Condition(Side(a), Side(a2, a3), StateConditions.IS_EQUAL)
c2 = Condition(Side(g3), Side(), StateConditions.IS_NOT_ZERO)
c.update_with(c1)
assert c == c2
c = Condition(Side(a, a2, a3, g3), Side(g2), StateConditions.IS_EQUAL)
c1 = Condition(Side(a, a2), Side(), StateConditions.IS_NOT_ZERO)
c2 = Condition(Side(a, a2, a3, g3), Side(g2), StateConditions.IS_EQUAL)
c.update_with(c1)
assert c == c2
"""test of compare """
c = Condition(Side(a, a2, a3, g3), Side(g2), StateConditions.IS_EQUAL)
c_copy = Condition(Side(a, a2, a3, g3), Side(g2), StateConditions.IS_EQUAL)
c2 = Condition(Side(a, a2, a3, g3, g2), Side(), StateConditions.IS_NOT_ZERO)
c2_copy = Condition(Side(a, a2, a3, g3, g2), Side(), StateConditions.IS_NOT_ZERO)
assert c.compare_conditions(c2) == CompareCondition.CONTRADICTION
assert c == c_copy and c2 == c2_copy
c = Condition(Side(a, g3), Side(), StateConditions.IS_ZERO)
c_copy = Condition(Side(a, g3), Side(), StateConditions.IS_ZERO)
c2 = Condition(Side(a, g3), Side(a2, a3, g2), StateConditions.IS_EQUAL)
c2_copy = Condition(Side(a, g3), Side(a2, a3, g2), StateConditions.IS_EQUAL)
assert c.compare_conditions(c2) == CompareCondition.NOT_EQUAL
assert c == c_copy and c2 == c2_copy
c = Condition(Side(a), Side(g3, g2), StateConditions.IS_EQUAL)
c_copy = Condition(Side(a), Side(g3, g2), StateConditions.IS_EQUAL)
c2 = Condition(Side(g3), Side(a, g2), StateConditions.IS_EQUAL)
c2_copy = Condition(Side(g3), Side(a, g2), StateConditions.IS_EQUAL)
assert c.compare_conditions(c2) == CompareCondition.EQUAL
assert c == c_copy and c2 == c2_copy
c = Condition(Side(a), Side(), StateConditions.IS_NOT_ZERO)
c2 = Condition(Side(g3), Side(), StateConditions.IS_NOT_ZERO)
assert c.compare_conditions(c2) == CompareCondition.NOT_EQUAL
""" """
c = Condition(Side(a, a2, a3), Side(g1, a3), StateConditions.IS_EQUAL)
c1 = Condition(Side(a), Side(g3), StateConditions.IS_EQUAL)
c2 = Condition(Side(a, a2), Side(g1), StateConditions.IS_EQUAL)
# c1 = Condition(Side(a, a2), Side(g1), StateConditions.IS_ZERO)
c3 = Condition(Side(g3), Side(), StateConditions.IS_ZERO)
c4 = Condition(Side(g2), Side(), StateConditions.IS_ZERO)
cc = CustomConditions()
cc.append_condition(c)
print "after append 0 \n" + str(cc)
cc.append_condition(c1)
print "after append 1 \n" + str(cc)
cc.append_condition(c2)
print "after append 2 \n" + str(cc)
cc.append_condition(c3)
print "after append 3 \n" + str(cc)
cc.append_condition(c4)
print "after append 4 \n" + str(cc)