-
Notifications
You must be signed in to change notification settings - Fork 478
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
setting warnings to errors changes the behaviour of np.asarray
on quantities
#892
Comments
In some sense this is a feature - numpy was told it was not allowed to convert to an int in the second case, so it picked an object array instead. What behavior would you like here instead? |
The use case here is catching warnings in unit tests. Obviously, if the warning -- that was converted to an error -- gets swallowed, the test won't work. |
what I would like is that warnings get passed through. So something like: try:
...
except Warning:
raise
except Exception:
... or catching using |
Based on discussion in numpy/numpy#14735, this seems to be a pint issue with using |
with the merge of numpy/numpy#14745 this won't happen on numpy master and from 1.18 on. We still need to decide if we want to change pint, though, before we can close this |
This relates to some other issues with Pint's handling of |
Using
warnings.filterwarnings
to promote warnings to errors changes the behaviour ofnp.asarray
(or rathernp.array
asnp.asarray
delegates to that):This happens with pint
0.9
, but also with the version from #764 (because__array_function__
does not allow overloadingnp.asarray
)Edit: I do think this is an issue within numpy, but I think it might help to also track this here. Possibly related: numpy/numpy#9761
The text was updated successfully, but these errors were encountered: