Skip to content

Commit

Permalink
Improve compatibility with numpy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Sep 9, 2024
1 parent 8cc50d9 commit 2b4db29
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions gwcs/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,19 +372,21 @@ def intersection(self, edge):
u = self._stop - self._start
v = edge._stop - edge._start
w = self._start - edge._start
D = np.cross(u, v)
D = _cross(u, v)

if np.allclose(np.cross(u, v), 0, rtol=0,
atol=1e2 * np.finfo(float).eps):
if abs(D) <= 1e2 * np.finfo(float).eps:
return np.array(self._start)

return np.cross(v, w) / D * u + self._start
return _cross(v, w) / D * u + self._start

def is_parallel(self, edge):
u = self._stop - self._start
v = edge._stop - edge._start
return np.allclose(np.cross(u, v), 0, rtol=0,
atol=1e2 * np.finfo(float).eps)
return abs(_cross(u, v)) <= 1e2 * np.finfo(float).eps

Check warning on line 385 in gwcs/region.py

View check run for this annotation

Codecov / codecov/patch

gwcs/region.py#L385

Added line #L385 was not covered by tests


def _cross(u, v):
return u[0] * v[1] - u[1] * v[0]


def _round_vertex(v):
Expand Down

0 comments on commit 2b4db29

Please sign in to comment.