hgrecco / pint

Operate and manipulate physical quantities in Python
http://pint.readthedocs.org/
Other
2.39k stars 467 forks source link

Parsing unit yield multiple results #1916

Closed rufuswilson closed 9 months ago

rufuswilson commented 9 months ago

I am using pint 0.23 and I faced the following problem.

I have a unit in short format (dat). It can refer to deci-technical_atmosphere or deca-metric_ton. Here is what I do at the moment

>> import pint
>> ureg = pint.UnitRegistry()
>> d = "[denisty]"
>> ureg.Unit("dat")
<Unit('decitechnical_atmosphere')>

How can I force it to give me the deca-metric_ton as it should be a [density]?

hgrecco commented 9 months ago

There is no way to force it that way. You can either use the full name or create a new definition file (it is super easy) in which the "other unit" in this case "technical_atmosphere"

rufuswilson commented 9 months ago

OK. Thanks for the answer.