Skip to content

Commit

Permalink
GmMultiPolyIntersector for python - bug with "not" vs "is None"
Browse files Browse the repository at this point in the history
  • Loading branch information
mkennard-aquaveo committed Jan 9, 2024
1 parent 88c3e51 commit 92e9b54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ def _run_test(self, pt1, pt2, poly_points, polys, poly_ids, t_vals, pts, startin
assert_str = f'Point {idx}[{i}], : Expected {point[i]}. Got {out_point[i]}'
assert math.isclose(out_point[i], point[i]), assert_str

def test_init(self):
"""Tests the initializer."""
with self.assertRaises(ValueError) as error:
grid.geometry.MultiPolyIntersector(None, [1, 2, 3])
assert str(error) == 'points is a required argument.'
with self.assertRaises(ValueError) as error:
grid.geometry.MultiPolyIntersector([[1, 2, 3]], None)
assert str(error) == 'polys is a required argument.'
with self.assertRaises(ValueError) as error:
grid.geometry.MultiPolyIntersector([[1, 2, 3]], [1, 2, 3], query='bob')
assert str(error) == 'query must be either "covered_by" or "intersects".'

def test_traverse_line_segment_1_out_out(self):
r"""A test.
Expand Down
6 changes: 3 additions & 3 deletions _package/xms/grid/geometry/multi_poly_intersector.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def __init__(self, points, polys, starting_id=1, query='covered_by', **kwargs) -
**kwargs (dict): Generic keyword arguments
"""
if 'instance' not in kwargs:
if not points:
raise ValueError('points is a required arguments.')
if not polys:
if points is None:
raise ValueError('points is a required argument.')
if polys is None:
raise ValueError('polys is a required argument.')
if query not in {'covered_by', 'intersects'}:
raise ValueError('query must be either "covered_by" or "intersects".')
Expand Down

0 comments on commit 92e9b54

Please sign in to comment.