Skip to content

Commit

Permalink
Fix Numpy 2 Compatibility
Browse files Browse the repository at this point in the history
Replace usage of np.product by np.prod.
  • Loading branch information
fthaler authored Jun 24, 2024
1 parent 33658cd commit 3cfc939
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions stencil_benchmarks/benchmarks_collection/stencils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def strides(self):

@property
def data_size(self):
return len(self.args) * np.product(self.domain) * self.dtype_size
return len(self.args) * np.prod(self.domain) * self.dtype_size

def inner_slice(self, shift=None, expand=None):
if shift is None:
Expand Down Expand Up @@ -255,8 +255,8 @@ def args(self):

@property
def data_size(self):
return (2 * np.product(self.domain) +
np.product(np.array(self.domain) + 4)) * self.dtype_size
return (2 * np.prod(self.domain) +
np.prod(np.array(self.domain) + 4)) * self.dtype_size

def verify_stencil(self, data_before, data_after):
validation.check_equality('inp', data_before.inp, data_after.inp)
Expand Down Expand Up @@ -323,7 +323,7 @@ def data_size(self):
else:
reads = 15 # including ccol + dcol, but not datacol
writes = 5 # including ccol + dcol, but not datacol
return (reads + writes) * np.product(self.domain) * self.dtype_size
return (reads + writes) * np.prod(self.domain) * self.dtype_size

def verify_stencil(self, data_before, data_after):
# pylint: disable=unsubscriptable-object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def blocked(self, data):
data.strides[2],
data.strides[0],
)
assert data.size == np.product(self.blocked_domain_with_halo)
assert data.size == np.prod(self.blocked_domain_with_halo)
blocked_view = np.lib.stride_tricks.as_strided(
data, self.blocked_domain_with_halo, blocked_strides)

Expand Down
2 changes: 1 addition & 1 deletion stencil_benchmarks/tools/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def check_equality(name, result, expected):
failure = ~np.isclose(result, expected, **_tolerances(result.dtype))
if not np.any(failure):
return
if result.ndim != 3 or np.product(result.shape) > 1000:
if result.ndim != 3 or np.prod(result.shape) > 1000:
report = _report_failures_large(result, expected, failure)
else:
report = _report_failures_small(result, expected, failure)
Expand Down

0 comments on commit 3cfc939

Please sign in to comment.