Skip to content

Commit

Permalink
Updated all np.product calls to np.prod (#5493)
Browse files Browse the repository at this point in the history
* Updated all np.product calls to np.prod

* added whats new

* review responses

* no typos here

* added link to name

* Update docs/src/whatsnew/latest.rst

Co-authored-by: Elias <[email protected]>

* Update docs/src/whatsnew/latest.rst

Co-authored-by: Elias <[email protected]>

---------

Co-authored-by: Elias <[email protected]>
  • Loading branch information
acchamber and ESadek-MO authored Sep 21, 2023
1 parent 10cec69 commit b6e39d7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ This document explains the changes made to Iris for this release
working properly. (Main pull request: :pull:`5437`, more detail:
:pull:`5430`, :pull:`5431`, :pull:`5432`, :pull:`5434`, :pull:`5436`)

#. `@acchamber`_ removed several warnings from iris related to Numpy 1.25 deprecations.
(:pull:`5493`)

#. `@trexfeathers`_ replaced all uses of the ``logging.WARNING`` level, in
favour of using Python warnings, following team agreement. (:pull:`5488`)

Expand All @@ -90,11 +93,14 @@ This document explains the changes made to Iris for this release




.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
core dev names are automatically included by the common_links.inc:
.. _@scottrobinson02: https://github.com/scottrobinson02
.. _@acchamber: https://github.com/acchamber


.. comment
Whatsnew resources in alphabetical order:
2 changes: 1 addition & 1 deletion lib/iris/fileformats/_structured_array_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def filter_strides_of_length(length):
# If we are to build another dimension on top of this possible
# structure, we need to compute the stride that would be
# needed for that dimension.
next_stride = np.product(
next_stride = np.prod(
[struct.size for (_, struct) in potential]
)

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def as_cubes(

cube_shape = getattr(pandas_index, "levshape", (pandas_index.nunique(),))
n_rows = len(pandas_structure)
if np.product(cube_shape) > n_rows:
if np.prod(cube_shape) > n_rows:
message = (
f"Not all index values have a corresponding row - {n_rows} rows "
f"cannot be reshaped into {cube_shape}. Consider padding with NaN "
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/integration/netcdf/test_thread_safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def tiny_chunks():
def _check_tiny_loaded_chunks(cube: Cube):
assert cube.has_lazy_data()
cube_lazy_data = cube.core_data()
assert np.product(cube_lazy_data.chunksize) < cube_lazy_data.size
assert np.prod(cube_lazy_data.chunksize) < cube_lazy_data.size

with dask.config.set({"array.chunk-size": "1KiB"}):
yield _check_tiny_loaded_chunks
Expand Down
6 changes: 3 additions & 3 deletions lib/iris/tests/unit/pandas/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ def test_ancillary_variable(self):
def test_3d_with_2d_coord(self):
df = self._create_pandas(index_levels=3)
coord_shape = df.index.levshape[:2]
coord_values = np.arange(np.product(coord_shape))
coord_values = np.arange(np.prod(coord_shape))
coord_name = "foo"
df[coord_name] = coord_values.repeat(df.index.levshape[-1])
result = iris.pandas.as_cubes(df, aux_coord_cols=[coord_name])
Expand All @@ -1089,7 +1089,7 @@ def test_3d_with_2d_coord(self):
def test_coord_varies_all_indices(self):
df = self._create_pandas(index_levels=3)
coord_shape = df.index.levshape
coord_values = np.arange(np.product(coord_shape))
coord_values = np.arange(np.prod(coord_shape))
coord_name = "foo"
df[coord_name] = coord_values
result = iris.pandas.as_cubes(df, aux_coord_cols=[coord_name])
Expand All @@ -1105,7 +1105,7 @@ def test_category_coord(self):
# increment.
df = self._create_pandas(index_levels=2)
coord_shape = df.index.levshape
coord_values = np.arange(np.product(coord_shape))
coord_values = np.arange(np.prod(coord_shape))
coord_name = "foo"

# Create a repeating value along a dimension.
Expand Down

0 comments on commit b6e39d7

Please sign in to comment.