Skip to content

Commit 16a504b

Browse files
committed
Fix: comparison in tests and code refactor
1 parent fc04b3e commit 16a504b

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

labfis/test/arithmetic_test.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
1-
from labfis import labfloat as lf
21
from itertools import combinations
2+
from labfis import labfloat
3+
34

45
def test_zeros():
5-
zeros = [lf(),lf(0),lf(0.),lf(0,0),
6-
lf(0.,0.),lf(0.,0),lf(0,0.),0,0.]
6+
zeros = [labfloat(), labfloat(0), labfloat(0.), labfloat(0, 0),
7+
labfloat(0., 0.), labfloat(0., 0), labfloat(0, 0.)]
8+
79
for z1, z2 in combinations(zeros, 2):
8-
assert z1 == z2
10+
print(z1, z2)
11+
assert list(z1) == list(z2)
912

1013
def test_indexing():
11-
assert lf(10,2)[:] == [10,2]
14+
assert labfloat(10, 2)[:] == (10, 2)
15+
1216

1317
def TestUnary():
14-
def test_pos(self):
15-
x = lf(100,4)
16-
assert x == +x
18+
def test_pos():
19+
x = labfloat(100, 4)
20+
y = +x
21+
22+
assert list(x) == list(y)
23+
24+
def test_neg_mean():
25+
x = labfloat(243, 2)
26+
y = labfloat(-243, 2)
27+
y = -y
28+
29+
assert list(x) == list(y)
30+
31+
def test_neg_uncertainty():
32+
x = labfloat(243, 2)
33+
y = labfloat(243, -2)
1734

18-
def test_neg():
19-
x = lf(243,2)
20-
y = lf(-243,2)
21-
assert x == -y
35+
assert list(x) == list(y)
2236

23-
#TODO: test cases for other arithmetic operators
37+
# TODO: test cases for other arithmetic operators

0 commit comments

Comments
 (0)