-
Notifications
You must be signed in to change notification settings - Fork 27
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
Make Postpic aware of Units in a proper way #100
Comments
Turns out pint does not subclass arrays. Quantitys contain arrays, just like the Field contains an array. Is it meaningful to put a container in a container? or should these things be somehow next to each other on the same level? Would subclassing be easier? How should we do this according to the numpy API? Numpys manual does talk about subclassing... |
|
|
|
|
One more option to assess: There is a package called python-quantities. It is not packed in arch, but its pure python, so pip can easily install it. The
then |
That seems nice! And using |
https://nrc-cnrc.github.io/MetroloPy/ is linked on the Scipy page https://www.scipy.org/topical-software.html . Maybe this is another option to assess. |
From my research there are a lot of packages available that allow unit-aware calculations in python. Most introduce a new class
Quantity
or similar, which represents a quantity with a value and a unit.They are also able to just handle bare units without values.
Most are able to also wrap a numpy
ndarray
inside aQuantity
.The most stable and mature packages seem to be
current versions of pint also support wrapping numpy addays.
Pint
Pint is lightweight and an arch linux package is available in the community repo. It wraps numpy arrays by subclassing them. I see three options of how we could use pint:
.unit
member ofField
andAxis
.grid_node
and.matrix
and get rid of the.unit
membernp.ndarray
, we subclass pint'sQuantity
astropy.units
I didn't test ist, is not packaged for arch.
sympy.physics.units
Large package, takes 400ms to import
The text was updated successfully, but these errors were encountered: