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 db44021
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gwcs/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,25 @@ 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,
if np.allclose(D, 0, rtol=0,
atol=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,
return np.allclose(_cross(u, v), 0, rtol=0,

Check warning on line 386 in gwcs/region.py

View check run for this annotation

Codecov / codecov/patch

gwcs/region.py#L386

Added line #L386 was not covered by tests
atol=1e2 * np.finfo(float).eps)


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


def _round_vertex(v):
x, y = v
return (int(round(x)), int(round(y)))

0 comments on commit db44021

Please sign in to comment.