From 9990f98f2e9e1a55f5d42206cbc6709a3efff418 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Thu, 2 Mar 2023 14:57:43 +0000 Subject: DEP: deprecate `product`, `cumproduct`, `sometrue`, `alltrue` [skip cirrus] --- numpy/core/fromnumeric.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'numpy/core/fromnumeric.py') diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index ed8b68ecd..6dfd95b96 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -3832,10 +3832,17 @@ def product(*args, **kwargs): """ Return the product of array elements over a given axis. + .. deprecated:: 1.25.0 + ``product`` is deprecated as of NumPy 1.25.0, and will be + removed in NumPy 2.0. Please use `prod` instead. + See Also -------- prod : equivalent function; see for details. """ + warnings.warn("`product` is deprecated as of NumPy 1.25.0, and will be " + "removed in NumPy 2.0. Please use `prod` instead.", + DeprecationWarning, stacklevel=2) return prod(*args, **kwargs) @@ -3844,10 +3851,17 @@ def cumproduct(*args, **kwargs): """ Return the cumulative product over the given axis. + .. deprecated:: 1.25.0 + ``cumproduct`` is deprecated as of NumPy 1.25.0, and will be + removed in NumPy 2.0. Please use `cumprod` instead. + See Also -------- cumprod : equivalent function; see for details. """ + warnings.warn("`cumproduct` is deprecated as of NumPy 1.25.0, and will be " + "removed in NumPy 2.0. Please use `cumprod` instead.", + DeprecationWarning, stacklevel=2) return cumprod(*args, **kwargs) @@ -3858,10 +3872,17 @@ def sometrue(*args, **kwargs): Refer to `any` for full documentation. + .. deprecated:: 1.25.0 + ``sometrue`` is deprecated as of NumPy 1.25.0, and will be + removed in NumPy 2.0. Please use `any` instead. + See Also -------- any : equivalent function; see for details. """ + warnings.warn("`sometrue` is deprecated as of NumPy 1.25.0, and will be " + "removed in NumPy 2.0. Please use `any` instead.", + DeprecationWarning, stacklevel=2) return any(*args, **kwargs) @@ -3870,8 +3891,15 @@ def alltrue(*args, **kwargs): """ Check if all elements of input array are true. + .. deprecated:: 1.25.0 + ``alltrue`` is deprecated as of NumPy 1.25.0, and will be + removed in NumPy 2.0. Please use `all` instead. + See Also -------- numpy.all : Equivalent function; see for details. """ + warnings.warn("`alltrue` is deprecated as of NumPy 1.25.0, and will be " + "removed in NumPy 2.0. Please use `all` instead.", + DeprecationWarning, stacklevel=2) return all(*args, **kwargs) -- cgit v1.2.1 From 3dcc33aa585339f36639f78da70bb35f26609bef Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Thu, 2 Mar 2023 21:08:21 +0000 Subject: MAINT: add dates/versions to deprecations, fix linter complaint [skip cirrus] [skip circle] --- numpy/core/fromnumeric.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'numpy/core/fromnumeric.py') diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 6dfd95b96..7ea2313d1 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -3821,6 +3821,7 @@ def round_(a, decimals=0, out=None): -------- around : equivalent function; see for details. """ + # 2023-02-28, 1.25.0 warnings.warn("`round_` is deprecated as of NumPy 1.25.0, and will be " "removed in NumPy 2.0. Please use `round` instead.", DeprecationWarning, stacklevel=2) @@ -3840,6 +3841,7 @@ def product(*args, **kwargs): -------- prod : equivalent function; see for details. """ + # 2023-03-02, 1.25.0 warnings.warn("`product` is deprecated as of NumPy 1.25.0, and will be " "removed in NumPy 2.0. Please use `prod` instead.", DeprecationWarning, stacklevel=2) @@ -3859,6 +3861,7 @@ def cumproduct(*args, **kwargs): -------- cumprod : equivalent function; see for details. """ + # 2023-03-02, 1.25.0 warnings.warn("`cumproduct` is deprecated as of NumPy 1.25.0, and will be " "removed in NumPy 2.0. Please use `cumprod` instead.", DeprecationWarning, stacklevel=2) @@ -3880,6 +3883,7 @@ def sometrue(*args, **kwargs): -------- any : equivalent function; see for details. """ + # 2023-03-02, 1.25.0 warnings.warn("`sometrue` is deprecated as of NumPy 1.25.0, and will be " "removed in NumPy 2.0. Please use `any` instead.", DeprecationWarning, stacklevel=2) @@ -3899,6 +3903,7 @@ def alltrue(*args, **kwargs): -------- numpy.all : Equivalent function; see for details. """ + # 2023-03-02, 1.25.0 warnings.warn("`alltrue` is deprecated as of NumPy 1.25.0, and will be " "removed in NumPy 2.0. Please use `all` instead.", DeprecationWarning, stacklevel=2) -- cgit v1.2.1