yunruse / Noether

Just another units package
MIT License
9 stars 0 forks source link

Imperial units: Explicit `UNITS_country` handling #44

Closed yunruse closed 11 months ago

yunruse commented 1 year ago

Imperial units will stay issue #1 for a long time to come I imagine. However, the whole idea is that this calculator refuses to let you trip over pesky unit confusions. It should not let you blithely go "I'll have a pint" and then cheat you out of 20%.

UNITS_country should by default be set to 'auto', requiring explicit setting; whenever needed, the PC language can be a nice heuristic.

Whenever an ambiguous unit is fetched, it should explicitly always provide AmbiguousUnitWarning: Assuming {unit_with_country_code} due to {reason}. To suppress this warning please explicitly import {unit_with_country_code}. where reason is either "PC language" or "config".

A UNITS_country_suppress_ambiguous_warning can suppress this warning if and only if UNITS_country is not "auto".

yunruse commented 11 months ago

This is really only a case of "customary US" or "imperial UK" for a very limited set of (mostly volume) units. I've added a UNITS_customary (default True).

This functionality (and I did half-implement it!) is a little overkill for a relatively minor problem, IMO.