unitwise icon indicating copy to clipboard operation
unitwise copied to clipboard

Can't normalise to SI units or handle common units

Open ahacking opened this issue 11 years ago • 3 comments

There does not seem to be an obvious way to normalise units to their SI counterpart.

I was expecting if I did Unitwise(3, 'foot') I would be able to do a to_si without having to know the dimension type a-priori. I was wanting to use this library for units handling and normalise all units regardless if they be length, mass, area, volume, etc before storing in DB but it seems not possible the way things are currently structured.

Also I noticed Unitwise(3, 'ft') on closer inspection seems to return mass, not length, making use of this library for common use cases rather impractical.

ahacking avatar Sep 09 '14 09:09 ahacking

As to the first, yes, you have to be explicit. Unitwise(3, 'foot').to_meter would probably be what you want. Unitwise doesn't have preferred unit mappings, though this is probably a reasonable feature.

Unitwise(3, 'ft') does indeed return a 'femtotonne'. However, this is a valid SI unit and 'ft' is it's official abbreviation. Unitwise implements the UCUM standard, so that is appropriate -- to create a foot unit, you can either use 'foot' or '[ft_i]' to describe a foot unit.

joshwlewis avatar Sep 09 '14 15:09 joshwlewis

Thanks, after my brief reading of UCUM I came to the conclusion it was a well intentioned but ultimately useless "standard" for common use cases since your average joe isn't going to use those conventions to describe a common length measurement like feet and inches.

I guess it works really well for the tiniest minority in the world who deal with femto scale mass units.

ahacking avatar Sep 09 '14 22:09 ahacking

I agree, UCUM (and by extension Unitwise) is built to encompass a huge scope of units. That is obviously useful for say fluid dynamics and heat transfer. There are probably some things I can do to make it more useful for simpler use cases (like perhaps only loading more common units by default).

In any case, thank you for your feedback. I've got some things to ponder.

joshwlewis avatar Sep 10 '14 01:09 joshwlewis