Skip to content

Commit

Permalink
Update to numpy new newbyteorder
Browse files Browse the repository at this point in the history
The numpy 2 migration guide suggests this solution. It does
work with numpy 1.
  • Loading branch information
timj committed Jan 24, 2025
1 parent 619a47b commit e5701e2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/test_imageIo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def doRoundTrip(self, image, compression=None, scaling=None):
with astropy.io.fits.open(filename) as hduList:
hdu = hduList[1 if isCompressed else 0]
if hdu.data.dtype.byteorder != '=':
hdu.data = hdu.data.byteswap().newbyteorder()
# numpy 2 suggests a view and two stage swap.
tmp_data = hdu.data.byteswap()
hdu.data = tmp_data.view(tmp_data.dtype.newbyteorder("S"))
return readImage, hdu

def runRoundTripTest(self, cls, compression=None, scaling=None, addNaN=False, checkAstropy=True, rtol=0):
Expand Down

0 comments on commit e5701e2

Please sign in to comment.