Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
kushalkolar opened this issue Feb 16, 2025 · 3 comments
Open

pint integration #729

kushalkolar opened this issue Feb 16, 2025 · 3 comments

Comments

@kushalkolar
Copy link
Member

https://github.com/hgrecco/pint

@kushalkolar
Copy link
Member Author

kushalkolar commented Feb 23, 2025

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')>

@clewis7

@clewis7
Copy link
Member

clewis7 commented Feb 24, 2025

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

@kushalkolar
Copy link
Member Author

I just am not sure how it feels from a dependency standpoint, even though the project seems active and well-supported.

I see it as a potential optional integration, like imgui

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

If a user has used pint with their array, then have fpl be aware of it, such as setting axes labels for example.

Needs more brainstorming I think

Yes definitely needs brainstorming, just posted this as a thought to get started :D

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

No branches or pull requests

2 participants