-
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
Applying numpy.cbrt (cubic root) loses quantity #807
Comments
Yes. This happens because |
When trying to find a workaround, I found that adding another dictionary entry "cbrt" : 1/3 here in quantity.py seems to work. Line 1321 in d804d93
from pint import UnitRegistry ur = UnitRegistry() a = ur.Quantity(100, "m ** 3") print(a) 100 meter ** 3 print(np.sqrt(a)) 10.0 meter ** 1.5 print(np.cbrt(a)) 4.641588833612778 meter Could you look into this as a hotfix? |
This was not added in #905 (even though it likely would have been easy to do so in retrospect). However, this should be an easy addition by defining a new unit operation in Lines 94 to 152 in 43fbae2
and adding the appropriate entry in: Lines 266 to 269 in 43fbae2
|
pint.__version__
'0.9'
a = ur.Quantity(100, "m ** 3")
print(a)
100 meter ** 3
print(np.sqrt(a))
10.0 meter ** 1.5
print(np.cbrt(a))
4.641588833612779
The text was updated successfully, but these errors were encountered: