Skip to content

Commit a521be6

Browse files
committed
first conversion tests
1 parent b86b2bd commit a521be6

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/test_conversions.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import pytest
2+
3+
from compas.geometry import Pointcloud
4+
from compas.tolerance import TOL
5+
from compas_occ.conversions import array1_from_points1
6+
from compas_occ.conversions import harray1_from_points1
7+
from compas_occ.conversions import points1_from_array1
8+
9+
10+
@pytest.mark.parametrize(
11+
"points1",
12+
[
13+
Pointcloud.from_bounds(10, 10, 10, 1),
14+
Pointcloud.from_bounds(10, 10, 10, 17),
15+
Pointcloud.from_bounds(10, 10, 10, 53),
16+
],
17+
)
18+
def test_array1_from_points1(points1):
19+
array1 = array1_from_points1(points1)
20+
assert array1.Length() == len(points1)
21+
22+
for item, point in zip(array1, points1):
23+
assert TOL.is_close(point.x, item.X())
24+
assert TOL.is_close(point.y, item.Y())
25+
assert TOL.is_close(point.z, item.Z())
26+
27+
28+
@pytest.mark.parametrize(
29+
"points1",
30+
[
31+
Pointcloud.from_bounds(10, 10, 10, 1),
32+
Pointcloud.from_bounds(10, 10, 10, 17),
33+
Pointcloud.from_bounds(10, 10, 10, 53),
34+
],
35+
)
36+
def test_harray1_from_points1(points1):
37+
array1 = harray1_from_points1(points1)
38+
assert array1.Length() == len(points1)
39+
40+
for item, point in zip(array1, points1):
41+
assert TOL.is_close(point.x, item.X())
42+
assert TOL.is_close(point.y, item.Y())
43+
assert TOL.is_close(point.z, item.Z())
44+
45+
46+
@pytest.mark.parametrize(
47+
"points1",
48+
[
49+
Pointcloud.from_bounds(10, 10, 10, 1),
50+
Pointcloud.from_bounds(10, 10, 10, 17),
51+
Pointcloud.from_bounds(10, 10, 10, 53),
52+
],
53+
)
54+
def test_points1_from_array1(points1):
55+
array1 = array1_from_points1(points1)
56+
points1 = points1_from_array1(array1)
57+
assert array1.Length() == len(points1)
58+
59+
for item, point in zip(array1, points1):
60+
assert TOL.is_close(point.x, item.X())
61+
assert TOL.is_close(point.y, item.Y())
62+
assert TOL.is_close(point.z, item.Z())

0 commit comments

Comments
 (0)