summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@gmail.com>2023-02-28 19:38:45 +0000
committerRalf Gommers <ralf.gommers@gmail.com>2023-02-28 23:15:40 +0000
commit768bbec24fff74cb59a173accf7fbeda6aca89a1 (patch)
tree041b801d111834c5e16b543d82482af5305f6d19 /numpy/core
parent486878b37fc7439a3b2b87747f50db9b62fea8eb (diff)
downloadnumpy-768bbec24fff74cb59a173accf7fbeda6aca89a1.tar.gz
DEP: deprecate `np.round_`
Closes gh-22617
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/__init__.py2
-rw-r--r--numpy/core/fromnumeric.py12
-rw-r--r--numpy/core/tests/test_deprecations.py6
3 files changed, 18 insertions, 2 deletions
diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py
index 1079c41df..f70743cbe 100644
--- a/numpy/core/__init__.py
+++ b/numpy/core/__init__.py
@@ -92,7 +92,7 @@ from . import einsumfunc
from .einsumfunc import *
del nt
-from .fromnumeric import amax as max, amin as min, round_ as round
+from .fromnumeric import amax as max, amin as min
from .numeric import absolute as abs
# do this after everything else, to minimize the chance of this misleadingly
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 7d3336f88..96f585066 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -21,7 +21,7 @@ __all__ = [
'argmin', 'argpartition', 'argsort', 'around', 'choose', 'clip',
'compress', 'cumprod', 'cumproduct', 'cumsum', 'diagonal', 'mean',
'ndim', 'nonzero', 'partition', 'prod', 'product', 'ptp', 'put',
- 'ravel', 'repeat', 'reshape', 'resize', 'round_',
+ 'ravel', 'repeat', 'reshape', 'resize', 'round', 'round_',
'searchsorted', 'shape', 'size', 'sometrue', 'sort', 'squeeze',
'std', 'sum', 'swapaxes', 'take', 'trace', 'transpose', 'var',
]
@@ -3337,6 +3337,9 @@ def around(a, decimals=0, out=None):
return _wrapfunc(a, 'round', decimals=decimals, out=out)
+round = around
+
+
def _mean_dispatcher(a, axis=None, dtype=None, out=None, keepdims=None, *,
where=None):
return (a, where, out)
@@ -3760,10 +3763,17 @@ def round_(a, decimals=0, out=None):
`~numpy.round_` is a disrecommended backwards-compatibility
alias of `~numpy.around` and `~numpy.round`.
+ .. deprecated:: 1.25.0
+ ``round_`` is deprecated as of NumPy 1.25.0, and will be
+ removed in NumPy 2.0. Please use `round` instead.
+
See Also
--------
around : equivalent function; see for details.
"""
+ 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)
return around(a, decimals=decimals, out=out)
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index ac4761b50..8ff52c885 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -901,3 +901,9 @@ class TestDeprecatedFinfo(_DeprecationTestCase):
# Deprecated in NumPy 1.25, 2023-01-16
def test_deprecated_none(self):
self.assert_deprecated(np.finfo, args=(None,))
+
+
+class TestRound_(_DeprecationTestCase):
+ # 2023-02-28, 1.25.0
+ def test_round_(self):
+ self.assert_deprecated(lambda: np.round_(np.array([1.5, 2.5, 3.5])))