-
Notifications
You must be signed in to change notification settings - Fork 48
pint
integration
#729
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
Comments
We might be able to create a general store model that uses pint to convert units and automatically spits things out if they make sense. Example here for time, but a user could define the units for each axis of a data array and as long as the units make sense a very general simple store model can sync them up. Can automatically set axes and stuff too if the units are defined for that dim. In [1]: import pint
In [2]: ureg = pint.UnitRegistry()
# define some sampling rates
In [3]: rate1 = 10 * ureg.Hz
In [4]: rate2 = 30 * ureg.Hz
# some timepoint
In [5]: timepoint = 1.5 * ureg.second
# define index which is really just dimensionless
In [11]: ureg.define("index = second * hertz")
# get index of that timepoint for rate2
In [12]: (timepoint * rate2).to("index")
Out[12]: <Quantity(45.0, 'index')>
# other way around, index to timepoint
In [15]: (75 * ureg("index") / rate1).to("second")
Out[15]: <Quantity(7.5, 'second')>
In [16]: (75 * ureg("index") / rate2).to("second")
Out[16]: <Quantity(2.5, 'second')> |
I think it would be cool for now to add an example using pint, but we should really consider whether it is something we would want to commit to long-term. I just am not sure how it feels from a dependency standpoint, even though the project seems active and well-supported. Also, would we want users directly interacting with pint to have to use fpl or would we want them to specify their units and then we set up the pint part under the hood Needs more brainstorming I think |
I see it as a potential optional integration, like imgui
If a user has used pint with their array, then have fpl be aware of it, such as setting axes labels for example.
Yes definitely needs brainstorming, just posted this as a thought to get started :D |
https://github.com/hgrecco/pint
The text was updated successfully, but these errors were encountered: