hgrecco / pint

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

API Mistake Found -> .to_preferred() #2067

Open gaokeyan123 opened 1 month ago

gaokeyan123 commented 1 month ago

if you run this,

a = 0 * UReg.kilogram / UReg.meter ** 3 / UReg.second print(a.to_preferred([UReg.hour]))

it gives error:

pint.errors.DimensionalityError: Cannot convert from 'kilogram / meter 3 / second' ([mass] / [length] 3 / [time]) to 'kilogram 1 / hour / meter 3' ([mass] 1 / [time] / [length] 3)

andrewgsavage commented 1 week ago

you also need to provide a mass and distance unit

we could change it so the units in the original quantity are used when there aren't any units of a dimension

e: ah maybe I've misunderstood this as it looks like it tried to do what I suggested. is it beacuse it's a 0 magnitude quantity?