From 2e3fb165d052cff12a6a64fe2543c2452808dd08 Mon Sep 17 00:00:00 2001 From: Michael Kennard Date: Thu, 4 Jan 2024 09:01:36 -0700 Subject: [PATCH] GmMultiPolyIntersector for python - fix CI errors --- .../multi_poly_intersector_pyt.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/_package/tests/unit_tests/geometry_tests/multi_poly_intersector_pyt.py b/_package/tests/unit_tests/geometry_tests/multi_poly_intersector_pyt.py index b11114db..14044187 100644 --- a/_package/tests/unit_tests/geometry_tests/multi_poly_intersector_pyt.py +++ b/_package/tests/unit_tests/geometry_tests/multi_poly_intersector_pyt.py @@ -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)