-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Fix a numpy deprecation related to dtype #1149
Conversation
Deprecated in numpy 1.21.0. This fixes 369 deprecation warnings in PyMC's test suite. See https://numpy.org/doc/stable/release/1.21.0-notes.html#the-dtype-attribute-must-return-a-dtype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I just fixed a related issue in 8867a72. Can you try the same numpy.obj2sctype
approach from there? It appears to be a concise way to determine whether or not a string or type
is a valid dtype.
I am sorry, but I am not sure how this would work. The function for a in ["float64", np.int8, np.int8(4).dtype]:
assert not isinstance(np.obj2sctype(a), np.dtype)
assert not isinstance(np.obj2sctype(a).dtype, np.dtype) It is possible that I am missing something though, as this dtype manipulation is extremely confusing to me. |
Likewise, I'm probably not thinking of the same issue that you are. Are the deprecation warnings caused by something like the following? import numpy as np
import aesara.tensor as at
np.dtype(at.vector("x"))
# <ipython-input-11-4480ef785bc5>:1: DeprecationWarning: in the future the `.dtype` attribute of a given datatype object must be a valid dtype instance. `data_type.dtype` may need to be coerced using `np.dtype(data_type.dtype)`. (Deprecated NumPy 1.20)
# np.dtype(at.vector("x")) |
Yes, I think that is the idea, at least for some of the warnings. |
I think I found a test that provides an example of the warnings you're talking about: In that case, |
Amazing, it looks like this fixes everything! Thank you very much! |
Deprecated in numpy 1.21.0.
This fixes 369 deprecation warnings in PyMC's test suite.
See https://numpy.org/doc/stable/release/1.21.0-notes.html#the-dtype-attribute-must-return-a-dtype
Thank you for opening a PR!
Here are a few important guidelines and requirements to check before your PR can be merged:
pre-commit
is installed and set up.Don't worry, your PR doesn't need to be in perfect order to submit it. As development progresses and/or reviewers request changes, you can always rewrite the history of your feature/PR branches.
If your PR is an ongoing effort and you would like to involve us in the process, simply make it a draft PR.