Skip to content

Commit 647f908

Browse files
committed
done
1 parent 4e8a1b7 commit 647f908

File tree

1 file changed

+59
-10
lines changed

1 file changed

+59
-10
lines changed

integration_tests/test_dict_04.py

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,80 @@
1-
from ltypes import i32, i64
1+
from ltypes import i32, i64, f64
2+
from math import pi, sin, cos
23

34
def test_dict():
4-
rollnumber2cpi: dict[tuple[i32, i32], i64] = {}
5+
terms2poly: dict[tuple[i32, i32], i64] = {}
6+
rtheta2coords: dict[tuple[i64, i64], tuple[f64, f64]] = {}
57
i: i32
8+
n: i64
69
size: i32 = 7000
710
size1: i32
8-
t: tuple[i32, i32]
11+
theta: f64
12+
r: f64
13+
coords: tuple[f64, f64]
14+
eps: f64 = 1e-12
915

16+
n = 0
1017
for i in range(1000, 1000 + size, 7):
11-
rollnumber2cpi[(i, i*i)] = int(i + i*i)
18+
terms2poly[(i, i*i)] = int(i + i*i)
19+
20+
theta = float(n) * pi
21+
r = float(i)
22+
rtheta2coords[(int(i), n)] = (r * sin(theta), r * cos(theta))
23+
24+
n += int(1)
1225

1326
size1 = size/7
27+
n = 0
1428
for i in range(1000, 1000 + size//2, 7):
15-
assert rollnumber2cpi.pop((i, i*i)) == int(i + i*i)
29+
assert terms2poly.pop((i, i*i)) == int(i + i*i)
30+
31+
theta = float(n) * pi
32+
r = float(i)
33+
coords = rtheta2coords.pop((int(i), n))
34+
assert abs(coords[0] - r * sin(theta)) <= eps
35+
assert abs(coords[1] - r * cos(theta)) <= eps
36+
1637
size1 = size1 - 1
17-
assert len(rollnumber2cpi) == size1
38+
assert len(terms2poly) == size1
39+
n += int(1)
1840

41+
n = 0
1942
for i in range(1000, 1000 + size//2, 7):
20-
rollnumber2cpi[(i, i*i)] = int(1 + 2*i + i*i)
43+
terms2poly[(i, i*i)] = int(1 + 2*i + i*i)
44+
45+
theta = float(n) * pi
46+
r = float(i)
47+
rtheta2coords[(int(i), n)] = (r * cos(theta), r * sin(theta))
2148

49+
n += int(1)
50+
51+
n = 0
2252
for i in range(1000, 1000 + size//2, 7):
23-
assert rollnumber2cpi[(i, i*i)] == (i + 1)*(i + 1)
53+
assert terms2poly[(i, i*i)] == (i + 1)*(i + 1)
54+
55+
theta = float(n) * pi
56+
r = float(i)
57+
assert abs(rtheta2coords[(int(i), n)][0] - r * cos(theta)) <= eps
58+
assert abs(rtheta2coords[(int(i), n)][1] - r * sin(theta)) <= eps
59+
60+
n += int(1)
2461

62+
n = 0
2563
for i in range(1000, 1000 + size, 7):
26-
rollnumber2cpi[(i, i*i)] = int(1 + 2*i + i*i)
64+
terms2poly[(i, i*i)] = int(1 + 2*i + i*i)
2765

66+
theta = float(n) * pi
67+
r = float(i)
68+
rtheta2coords[(int(i), n)] = (r * cos(theta), r * sin(theta))
69+
n += int(1)
70+
71+
n = 0
2872
for i in range(1000, 1000 + size, 7):
29-
assert rollnumber2cpi[(i, i*i)] == (i + 1)*(i + 1)
73+
assert terms2poly[(i, i*i)] == (i + 1)*(i + 1)
74+
75+
theta = float(n) * pi
76+
r = float(i)
77+
assert abs(r**2 - rtheta2coords[(int(i), n)][0]**2 - r**2 * sin(theta)**2) <= eps
78+
n += int(1)
3079

3180
test_dict()

0 commit comments

Comments
 (0)