8000 DEP: deprecate np.finfo(None) by dshintani404 · Pull Request #23011 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DEP: deprecate np.finfo(None) #23011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change exception to warning
  • Loading branch information
dshintani404 committed Jan 16, 2023
commit 8f5747057b7f80dc84d7b1daa2dd97f1af68f40d
7 changes: 6 additions & 1 deletion numpy/core/getlimits.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,12 @@ class finfo:

def __new__(cls, dtype):
if dtype is None:
raise ValueError("Invalid data type.")
warnings.warn(
"dtype cannot be None. This behavior "
"will raise an error in the future.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the warning is indeed the correct path. Could you add a test as well? It can live in test_deprecations.py.

Please add (Deprecated in NumPy 1.25) or something similar to the message. Could also lead with finfo() dtype ... just to make it even easier to find where it is coming from.

The last thing is that both here and in the test, we try to add a comment:

# Deprecated in NumPy 1.25, 2022-01-16

Or similar. This makes it much easier to find and to act on in the future.

DeprecationWarning,
stacklevel=2
)

try:
dtype = numeric.dtype(dtype)
Expand Down
0