Skip to content

Commit

Permalink
Fix numpy 2 warnings emitted from skymatch (spacetelescope#8892)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamJamieson authored and hayescr committed Oct 29, 2024
1 parent efae7f5 commit bc38872
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes/8892.skymatch.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Resolve warnings emitted by NumPy 2 when running skymatch.
15 changes: 11 additions & 4 deletions jwst/skymatch/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,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)

if np.allclose(np.cross(u, v), 0, rtol=0,
# Find the determinant of the matrix formed by the vectors u and v
# Note: Originally this was computed using a numpy "2D" cross product,
# however, this functionality has been deprecated and slated for
# removal.
D = np.linalg.det([u, v])

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
# See note above
return np.linalg.det([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,
# See note in intersection method
return np.allclose(np.linalg.det([u, v]), 0, rtol=0,
atol=1e2 * np.finfo(float).eps)


Expand Down

0 comments on commit bc38872

Please sign in to comment.