Skip to content

Commit 566dc03

Browse files
committed
add test
1 parent fb40418 commit 566dc03

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/compas/data/test_json_numpy.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,24 @@ def test_json_numpy():
1515

1616
except ImportError:
1717
pass
18+
19+
20+
try:
21+
import numpy as np
22+
23+
try:
24+
np_float = np.float_
25+
except AttributeError:
26+
np_float = np.float64
27+
28+
def test_json_numpy_float():
29+
before = [
30+
np.array([1, 2, 3], dtype=np_float),
31+
np.array([1.0, 2.0, 3.0]),
32+
np_float(1.0),
33+
]
34+
after = compas.json_loads(compas.json_dumps(before))
35+
assert after == [[1, 2, 3], [1.0, 2.0, 3.0], 1.0]
36+
37+
except ImportError:
38+
pass

0 commit comments

Comments
 (0)