-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_poly_pair.py
44 lines (35 loc) · 980 Bytes
/
test_poly_pair.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
from math_helper import MathHelper
from pair import Pair
from commutative_ring import verify_ring_properties
from lib.test_helpers import assert_equal, assert_str, run_test
from poly import SingleVarPoly
from poly_pair import PairPoly
@run_test
def show_basics():
c1 = PairPoly.const(Pair(1, 14))
c2 = PairPoly.const(Pair(41, 7))
t = PairPoly.t
assert_equal(t.type_string, "SingleVarPoly.Pair")
p = (t + c1) * (t + c2)
assert_str(p, "t**2+((42, 21))*t+(41, 98)")
assert_equal(
p.eval(Pair(1000000, 10000)),
Pair(1000042000041, 100210098),
)
@run_test
def check_is_ring():
c1 = PairPoly.const(Pair(111, -214))
c2 = PairPoly.const(Pair(421, 77))
t = PairPoly.t
samples = [
t + c1,
c1 * c2,
c2**4,
(t + c1) ** 3,
]
math = MathHelper(
value_type=SingleVarPoly,
zero=PairPoly.zero,
one=PairPoly.one,
)
verify_ring_properties(math, samples)