Skip to content

Commit

Permalink
Merge branch 'lint_test_folder' into 'master'
Browse files Browse the repository at this point in the history
Also lint test folder

See merge request Oslandia/py3dtiles!103
  • Loading branch information
autra committed May 16, 2022
2 parents 3878381 + 6576aea commit 0f9f07f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ flake8:
before_script:
- python -m pip install -U flake8
script:
- flake8 setup.py py3dtiles/ docs/
- flake8 setup.py py3dtiles/ docs/ tests/
only:
refs:
- merge_requests
Expand Down
24 changes: 13 additions & 11 deletions tests/test_wkb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def complex_polygon():
# / |
# 2x---------x 3
# the first few vertices seems to indicate an inverse winding order
return [
return [
[
np.array([0, 1, 0], dtype=np.float32),
np.array([0.5, 0.5, 0], dtype=np.float32),
Expand Down Expand Up @@ -136,8 +136,9 @@ def test_triangulate_winding_order_complex(complex_polygon):
triangles = wkb_utils.triangulate(complex_polygon)
assert len(triangles[0]) == 3, 'Should generate 2 triangles'
crossprod_triangle1 = np.cross(
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0])
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0]
)
crossprod_triangle1 /= np.linalg.norm(crossprod_triangle1)
assert \
all(crossprod_triangle1 == np.array([0, 0, 1], dtype=np.float32)), \
Expand All @@ -147,8 +148,8 @@ def test_triangulate_winding_order_complex(complex_polygon):
def test_triangulate_winding_order_stars(clockwise_star):
triangles = wkb_utils.triangulate(clockwise_star)
crossprod_triangle1 = np.cross(
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0])
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0])
crossprod_triangle1 /= np.linalg.norm(crossprod_triangle1)
assert all(crossprod_triangle1 == np.array([0, 0, -1], dtype=np.float32)), \
'Check winding order is coherent with vertex order: clockwise'
Expand All @@ -157,8 +158,8 @@ def test_triangulate_winding_order_stars(clockwise_star):
def test_triangulate_winding_order_counter_clockwise_stars(counterclockwise_star):
triangles = wkb_utils.triangulate(counterclockwise_star)
crossprod_triangle1 = np.cross(
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0])
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0])
crossprod_triangle1 /= np.linalg.norm(crossprod_triangle1)
assert all(crossprod_triangle1 == np.array([0, 0, 1], dtype=np.float32)), \
'Check winding order is coherent with vertex order: counter-clockwise'
Expand All @@ -167,8 +168,8 @@ def test_triangulate_winding_order_counter_clockwise_stars(counterclockwise_star
def test_triangulate_winding_order_counter_clockwise_zx_stars(counterclockwise_zx_star):
triangles = wkb_utils.triangulate(counterclockwise_zx_star)
crossprod_triangle1 = np.cross(
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0])
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0])
crossprod_triangle1 /= np.linalg.norm(crossprod_triangle1)
# check the 2nd dimension is the largest by far and is positive
assert crossprod_triangle1[1] > 0.8,\
Expand All @@ -178,12 +179,13 @@ def test_triangulate_winding_order_counter_clockwise_zx_stars(counterclockwise_z
def test_big_poly_winding_order(big_poly):
triangles = wkb_utils.triangulate(big_poly)
crossprod_triangle1 = np.cross(
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0])
triangles[0][0][1] - triangles[0][0][0],
triangles[0][0][2] - triangles[0][0][0])
crossprod_triangle1 /= np.linalg.norm(crossprod_triangle1)
assert all(crossprod_triangle1 == np.array([0, 0, 1], dtype=np.float32)), \
'Check winding order is coherent with vertex order: counter-clockwise'


################
# benchmarking #
################
Expand Down

0 comments on commit 0f9f07f

Please sign in to comment.