Skip to content

Commit

Permalink
Fix numpy depreciated np.product and OverflowError error on uint8 mask (
Browse files Browse the repository at this point in the history
fix #5)
  • Loading branch information
seignovert committed Oct 22, 2024
1 parent 7cee4de commit 1a0fa3f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions pyvims/interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ def cube_interp(xy, data, res, contour=False, method='cubic'):
m = mask(grid, contour)

if np.ndim(data) == 3:
z = np.moveaxis([z[:, :, 0], z[:, :, 1], z[:, :, 2], 255 * np.int8(~m)], 0, 2)
z = np.moveaxis([
z[:, :, 0],
z[:, :, 1],
z[:, :, 2],
255 * np.uint8(~m),
], 0, 2)
else:
z = np.ma.array(z, mask=m)

Expand Down Expand Up @@ -264,7 +269,7 @@ def cube_interp_filled(xy, data, res, contour, method='cubic'):

if np.ndim(data) == 3:
# Add alpha channel outside the contour
z = rgba(z[:, :, 0], z[:, :, 1], z[:, :, 2], np.int8(~m))
z = rgba(z[:, :, 0], z[:, :, 1], z[:, :, 2], np.uint8(~m))
else:
# Mask the data outside the contour
z = np.ma.array(z, mask=m)
Expand Down
2 changes: 1 addition & 1 deletion pyvims/projections/equirectangular.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def equi_interp(xy, data, res, contour, sc, r, npix=1440, method='cubic'):
gz_interp[:, :, 0],
gz_interp[:, :, 1],
gz_interp[:, :, 2],
255 * np.int8(~m)
255 * np.uint8(~m),
], 0, 2)
else:
z_mask = np.ma.array(gz_interp, mask=m)
Expand Down
4 changes: 2 additions & 2 deletions pyvims/projections/sky_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def sky_pixels(radec, m_sky):
"""
s = np.shape(radec)
npix = int(np.product(s) / 2)
npix = int(np.prod(s) / 2)
pix = xy(*np.reshape(radec, (2, npix)), m_sky)
return np.reshape(pix, s)

Expand Down Expand Up @@ -147,7 +147,7 @@ def sky_grid(grid, m_sky):
"""
s = np.shape(grid)
npix = int(np.product(s) / 2)
npix = int(np.prod(s) / 2)
x, y = np.reshape(grid, (2, npix))
return radec(x, y, m_sky).reshape(s)

Expand Down
6 changes: 3 additions & 3 deletions pyvims/vims.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ def _flat(self, array):
Returns
-------
np.array
Flattenned array.
Flattened array.
"""
ndim = int(np.product(np.shape(array)) / self.NP)
ndim = int(np.prod(np.shape(array)) / self.NP)
return np.reshape(array, (ndim, self.NP))

def _grid(self, array):
Expand All @@ -317,7 +317,7 @@ def _grid(self, array):
Gridded array.
"""
ndim = int(np.product(np.shape(array)) / self.NP)
ndim = int(np.prod(np.shape(array)) / self.NP)
return np.reshape(array, (ndim, self.NL, self.NS))

@staticmethod
Expand Down

0 comments on commit 1a0fa3f

Please sign in to comment.