Skip to content
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

Operations between arrays of quantity scalars and quantity holding array resulting in incorrect units #1674

Closed
andrewgsavage opened this issue Dec 10, 2022 · 0 comments · Fixed by #1677

Comments

@andrewgsavage
Copy link
Collaborator

When implementing array_ufunc in pint-pandas I've hit some odd results.

import pint
ureg =pint.UnitRegistry()

Q_ = ureg.Quantity
q_arr = Q_(np.array([1,2]),"m")
arr_of_q = np.array([Q_(1,"m"), Q_(2,"m")], dtype="object")
C:\Users\A\AppData\Local\Temp\ipykernel_16288\106945721.py:3: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.

print(arr_of_q)
[<Quantity(1, 'meter')> <Quantity(2, 'meter')>]


print(q_arr*arr_of_q)
[<Quantity(1, 'meter')> <Quantity(4, 'meter')>] meter # odd to have meters inside and outside array


print(arr_of_q*q_arr)
[1 4] meter # Should be m^2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant