summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/getlimits.py9
-rw-r--r--numpy/core/tests/test_deprecations.py6
2 files changed, 15 insertions, 0 deletions
diff --git a/numpy/core/getlimits.py b/numpy/core/getlimits.py
index 5baeb97fe..8146c4644 100644
--- a/numpy/core/getlimits.py
+++ b/numpy/core/getlimits.py
@@ -471,6 +471,15 @@ class finfo:
_finfo_cache = {}
def __new__(cls, dtype):
+ if dtype is None:
+ # Deprecated in NumPy 1.25, 2023-01-16
+ warnings.warn(
+ "finfo() dtype cannot be None. This behavior will "
+ "raise an error in the future. (Deprecated in NumPy 1.25)",
+ DeprecationWarning,
+ stacklevel=2
+ )
+
try:
dtype = numeric.dtype(dtype)
except TypeError:
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 83777cc9c..d82ae001c 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -1107,3 +1107,9 @@ class TestRemovedGlobals:
msg = f".*\n`np.{name}` was a deprecated alias for the builtin"
with pytest.raises(AttributeError, match=msg):
getattr(np, name)
+
+
+class TestDeprecatedFinfo(_DeprecationTestCase):
+ # Deprecated in NumPy 1.25, 2023-01-16
+ def test_deprecated_none(self):
+ self.assert_deprecated(np.finfo, args=(None,))