8000 DEP: deprecate np.finfo(None) (#23011) · numpy/numpy@0cfbd3c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cfbd3c

Browse files
authored
DEP: deprecate np.finfo(None) (#23011)
Deprecate np.finfo(None), it may be that we should more generally deprecate `np.dtype(None)` but this is a start and particularly weird maybe. Closes gh-14684
1 parent e2fccd9 commit 0cfbd3c

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* ``np.finfo(None)`` is deprecated.

numpy/core/getlimits.py

Lines changed: 9 additions & 0 deletions
< 8000 td data-grid-cell-id="diff-4fb697c02deabd8f861c8019b98683c739fe05761daf9021684dfa0a7d24d46a-473-480-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,15 @@ class finfo:
471471
_finfo_cache = {}
472472

473473
def __new__(cls, dtype):
474+
if dtype is None:
475+
# Deprecated in NumPy 1.25, 2023-01-16
476+
warnings.warn(
477+
"finfo() dtype cannot be None. This behavior will "
478+
"raise an error in the future. (Deprecated in NumPy 1.25)",
479+
DeprecationWarning,
480+
stacklevel=2
481+
)
482+
474483
try:
475484
dtype = numeric.dtype(dtype)
476485
except TypeError:

numpy/core/tests/test_deprecations.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,3 +1107,9 @@ def test_attributeerror_includes_info(self, name):
11071107
msg = f".*\n`np.{name}` was a deprecated alias for the builtin"
11081108
with pytest.raises(AttributeError, match=msg):
11091109
getattr(np, name)
1110+
1111+
1112+
class TestDeprecatedFinfo(_DeprecationTestCase):
1113+
# Deprecated in NumPy 1.25, 2023-01-16
1114+
def test_deprecated_none(self):
1115+
self.assert_deprecated(np.finfo, args=(None,))

0 commit comments

Comments
 (0)
0