-
Notifications
You must be signed in to change notification settings - Fork 473
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
Calling np.sqrt on a pint quantity has a side effect on the pint quantity #622
Comments
Yes. This is true not only for Pint but for everything: >>> import numpy as np
>>> type(np.sqrt(4))
<class 'numpy.float64'> While it looks unexpected, it is actually what numpy does |
The issue isn't changing data type between source and result. The issue is that |
This is also described in issue #509. I believe it could be something related to this part of the code: Lines 1341 to 1345 in 0c4a950
Maybe this conversion could be done only when the magnitude is iterable? |
I am closing this as it is taken care by #925 |
957: Add parameterized test for type immutability r=hgrecco a=jthielen As discussed in #925, this adds a parameterized test to verify that the internal type is not mutated under common operations (as encountered in #399, #481, #509, #622, #678). - [x] Closes #925, Closes #481 - [x] Executed ``black -t py36 . && isort -rc . && flake8`` with no errors - [x] The change is fully covered by automated unit tests - ~~Documented in docs/ as appropriate~~ - [x] Added an entry to the CHANGES file Co-authored-by: Jon Thielen <github@jont.cc>
Strange numpy/pint interaction. When I call
np.sqrt
on a pint quantity, it has the side effect of changing the type of the object in the pint quantity. When I use**(1/2)
instead ofnp.sqrt
, this doesn't happen.The text was updated successfully, but these errors were encountered: