pint
pint copied to clipboard
Get the dimensionality of quantities whose units are ratios of the same unit
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]?