Working with python-pint
, let's suppose I have a quantity defined as
<Quantity(1.0, 'gram * kilopascal / joule')>
which is equivalent to kilogram/m3
. Now, when I try to get that using to_base_units
i get:
den.to_base_units()
<Quantity(1000.0, 'gram / meter ** 3')>
which is fine, except I wished the magnitude was still 1, and the units were, instead, <Quantity(1.0, 'kilogram / meter ** 3')>
, for user-friendliness purposes. Is there a way to achieve that?
By the way, this happens with many different units throughout my program and there's no (easy) way to know which are the correct units for it to be converted to, which prevents me from using convert_to
method. In this case it should change from 1000 gram
to kilogram
, for example, but in the next case it can be from 0.001 meter
to 1 milimeter
and so on.
I know that pint 0.7 (I'm still using 0.6) has a new system option, but I also couldn't solve it with that.
Cheers