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

Get the dimensionality of quantities whose units are ratios of the same unit #2000

Open
yerkoescalona opened this issue May 29, 2024 · 0 comments

Comments

@yerkoescalona
Copy link

Hello :)
A bit associated with issue #551
but in my case, I want to solve this kind of problem by creating new units like:

>>> from pint import UnitRegistry
>>> ureg = UnitRegistry()
>>> ureg.define('gram_solute = [solute] = g_solute')
>>> ureg.define('gram_solvent = [solvent] = g_solvent')
>>> ureg("g_solute/g_solvent")
1.0 gram_solute / gram_solvent

But somewhere in my code, I need to move from g/g to gram_solute / gram_solvent
I wanted to use the parser of pint to identify the dimensionality [mass] / [mass]

>>> from pint.util import ParserHelper
>>> ParserHelper.from_string('g/g') 
<ParserHelper(1.0, {})>

But quite earlier, the results are dimensionless.

Do you have an idea how I can use the pint parser to get to know that I have: [mass] / [mass]?

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

1 participant