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

Support for physical units through pint #2788

Closed
gipert opened this issue Oct 31, 2023 · 4 comments
Closed

Support for physical units through pint #2788

gipert opened this issue Oct 31, 2023 · 4 comments
Labels
feature New feature or request

Comments

@gipert
Copy link

gipert commented Oct 31, 2023

Description of new feature

pint is a nice Python units library with built-in support for NumPy arrays and other integrations. Would be nice to be able to propagate units with Awkward arrays too. Is there any interest/plan to have this in the future?

@gipert gipert added the feature New feature or request label Oct 31, 2023
@agoose77
Copy link
Collaborator

Duplicate of #2468! :)

@gipert
Copy link
Author

gipert commented Oct 31, 2023

Ok! I thought about opening a new one, since there was not mention to Pint in #2468.

@jpivarski
Copy link
Member

That was probably in private conversations, then: we're thinking of using a Pint UnitRegistry as a source of truth about units and their relationships, but some of the handling would have to be manual. (For example, we have to implement reducers ourselves. If an array has units, ak.sum would preserve those units but ak.prod shouldn't even be possible. ak.any and ak.all would drop the units when converting numbers into booleans...)

Thus, we're recognizing Pint as the standard way to express units, to the exclusion of any other libraries that might do the same thing, and we'll try to reuse code in Pint as much as possible (e.g. in unit conflicts, which of the two should be converted to the other, and what do we multiply by to get that conversion?), but there will be limits and some things will need to be computed by hand in Awkward.

@gipert
Copy link
Author

gipert commented Oct 31, 2023

Sounds great! Thanks a lot for elaborating. Looking forward to it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants