Skip to content

Commit

Permalink
Use np.prod instead of np.product
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Mar 9, 2023
1 parent a3f4ae6 commit 5785cae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions astropy/convolution/convolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def convolve_fft(
kernshape = kernel.shape

array_size_B = (
np.product(arrayshape, dtype=np.int64) * np.dtype(complex_dtype).itemsize
np.prod(arrayshape, dtype=np.int64) * np.dtype(complex_dtype).itemsize
) * u.byte
if array_size_B > 1 * u.GB and not allow_huge:
raise ValueError(
Expand Down Expand Up @@ -838,7 +838,7 @@ def convolve_fft(

# perform a second check after padding
array_size_C = (
np.product(newshape, dtype=np.int64) * np.dtype(complex_dtype).itemsize
np.prod(newshape, dtype=np.int64) * np.dtype(complex_dtype).itemsize
) * u.byte
if array_size_C > 1 * u.GB and not allow_huge:
raise ValueError(
Expand All @@ -852,12 +852,12 @@ def convolve_fft(
# (kernel*array)fft +
# optional(weight image + weight_fft + weight_ifft) +
# optional(returned_fft))
# total_memory_used_GB = (np.product(newshape)*np.dtype(complex_dtype).itemsize
# total_memory_used_GB = (np.prod(newshape)*np.dtype(complex_dtype).itemsize
# * (5 + 3*((interpolate_nan or ) and kernel_is_normalized))
# + (1 + (not return_fft)) *
# np.product(arrayshape)*np.dtype(complex_dtype).itemsize
# + np.product(arrayshape)*np.dtype(bool).itemsize
# + np.product(kernshape)*np.dtype(bool).itemsize)
# np.prod(arrayshape)*np.dtype(complex_dtype).itemsize
# + np.prod(arrayshape)*np.dtype(bool).itemsize
# + np.prod(kernshape)*np.dtype(bool).itemsize)
# ) / 1024.**3

# separate each dimension by the padding size... this is to determine the
Expand Down
2 changes: 1 addition & 1 deletion astropy/modeling/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def test_prepare_outputs_sparse_grid():
"""

shape = (3, 3)
data = np.arange(np.product(shape)).reshape(shape) * u.m / u.s
data = np.arange(np.prod(shape)).reshape(shape) * u.m / u.s

points_unit = u.pix
points = [np.arange(size) * points_unit for size in shape]
Expand Down
2 changes: 1 addition & 1 deletion examples/io/skip_create-large-fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

shape = tuple(header[f'NAXIS{ii}'] for ii in range(1, header['NAXIS']+1))
with open('large.fits', 'rb+') as fobj:
fobj.seek(len(header.tostring()) + (np.product(shape) * np.abs(header['BITPIX']//8)) - 1)
fobj.seek(len(header.tostring()) + (np.prod(shape) * np.abs(header['BITPIX']//8)) - 1)
fobj.write(b'\0')

##############################################################################
Expand Down

0 comments on commit 5785cae

Please sign in to comment.