Skip to content

Commit

Permalink
GmMultiPolyIntersector for python - fix CI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mkennard-aquaveo committed Jan 4, 2024
1 parent 54969b9 commit 2e3fb16
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,32 @@ def _run_test(self, x1, y1, x2, y2, points, polys, expected_poly_ids, expected_t
"""Runs the test."""
mpi = grid.geometry.MultiPolyIntersector(points, polys)
poly_ids, t_vals, pts = mpi.traverse_line_segment(x1, y1, x2, y2)
assert poly_ids == expected_poly_ids, f'Expected {expected_poly_ids}. Got {poly_ids}.'

# Check poly ids
assert len(poly_ids) == len(expected_poly_ids)
assert_str = f'Expected {expected_poly_ids}. Got {poly_ids}'
assert poly_ids == expected_poly_ids, assert_str

# Check t vals
# assert np.testing.assert_allclose(t_vals, expected_t_vals), f'Expected {expected_t_vals}. Got {t_vals}.'
assert len(t_vals) == len(expected_t_vals)
for t_val, expected_t_val in zip(t_vals, expected_t_vals):
assert_str = f'Expected {expected_t_val}. Got {t_val}'
assert math.isclose(t_val, expected_t_val), assert_str
for point, expected_point in zip(self._zeroed_z(pts), self._zeroed_z(expected_points)):
assert np.testing.assert_allclose(point, expected_point)

# Check points
assert len(pts) == len(expected_points)
for idx, point, expected_point in enumerate(zip(self._zeroed_z(pts), self._zeroed_z(expected_points))):
for i in range(3):
assert_str = f'Point {idx}[{i}], : Expected {expected_point[i]}. Got {point[i]}'
assert math.isclose(point[i], expected_point[i]), assert_str

def test_traverse_line_segment_1_out_out(self):
"""A test."""
pts = [[0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0]]
polys = [[0, 1, 2, 3]]
expected_ids = (1, -1)
expected_t_vals = (0.0833333, 0.916667)
expected_t_vals = (0.08333333333333333, 0.91666666666666667)
expected_points = ((0.0, 5.0, 0.0), (10.0, 5.0, 0.0))
self._run_test(-1, 5, 11, 5, pts, polys, expected_ids, expected_t_vals, expected_points)

Expand Down

0 comments on commit 2e3fb16

Please sign in to comment.