From 3a39854afe5032bb9dd1b7b4f09c24667d3c7550 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 10 Mar 2023 18:08:17 -0800 Subject: [PATCH 1/2] DEPS: Address np.cumproduct deprecation --- pandas/core/reshape/util.py | 2 +- pandas/tests/groupby/test_libgroupby.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/reshape/util.py b/pandas/core/reshape/util.py index 1154940f2c4a6..9b5305f36bd49 100644 --- a/pandas/core/reshape/util.py +++ b/pandas/core/reshape/util.py @@ -41,7 +41,7 @@ def cartesian_product(X) -> list[np.ndarray]: return [] lenX = np.fromiter((len(x) for x in X), dtype=np.intp) - cumprodX = np.cumproduct(lenX) + cumprodX = np.cumprod(lenX) if np.any(cumprodX < 0): raise ValueError("Product space too large to allocate arrays!") diff --git a/pandas/tests/groupby/test_libgroupby.py b/pandas/tests/groupby/test_libgroupby.py index 4cea6d10af9e0..9552d67bfe992 100644 --- a/pandas/tests/groupby/test_libgroupby.py +++ b/pandas/tests/groupby/test_libgroupby.py @@ -194,7 +194,7 @@ def test_cython_group_transform_cumsum(np_dtype): def test_cython_group_transform_cumprod(): # see gh-4095 dtype = np.float64 - pd_op, np_op = group_cumprod, np.cumproduct + pd_op, np_op = group_cumprod, np.cumprod _check_cython_group_transform_cumulative(pd_op, np_op, dtype) From 002ccd3f105c774aa7661acbbf65dcc1ee2912c0 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 10 Mar 2023 19:26:29 -0800 Subject: [PATCH 2/2] Another np.product --- pandas/core/reshape/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/reshape/util.py b/pandas/core/reshape/util.py index 9b5305f36bd49..a92b439927fff 100644 --- a/pandas/core/reshape/util.py +++ b/pandas/core/reshape/util.py @@ -60,7 +60,7 @@ def cartesian_product(X) -> list[np.ndarray]: return [ tile_compat( np.repeat(x, b[i]), - np.product(a[i]), # pyright: ignore[reportGeneralTypeIssues] + np.prod(a[i]), # pyright: ignore[reportGeneralTypeIssues] ) for i, x in enumerate(X) ]