You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a case_sensitive option to BaseRegistry which defaults to True
Modify the existing case_sensitive options on get_name, parse_unit_name, parse_pattern, and parse_expression to default to None instead of True, and have None be replaced within the methods with the registry's case_sensitive option
Add analogous case_sensitive kwarg to parse_units
Optional: add analogous case_sensitive kwarg to any other public registry method that ends up using parse_unit_name (or something that uses it, recursively) so that it can be appropriately passed along.
This would allow something like the following to become valid, so that a greater extent of CF unit compliance can be achieved:
Thanks @jthielen for the comprehensive and clear proposal. I think that your solution covers all major points and the suggetsted defaults are good not only to adhere to pint philosophy but also to maintain backwards compatibility. I also agree with point 4.
I will be happy to review and merge this PR when ready.
Thanks @jthielen for the comprehensive and clear proposal. I think that your solution covers all major points and the suggetsted defaults are good not only to adhere to pint philosophy but also to maintain backwards compatibility. I also agree with point 4.
I will be happy to review and merge this PR when ready.
Sounds great, thanks! I'll add this to my queue of PR's to work on across projects the next couple days.
In our quest to handle CF compliant/UDUNITS style units in MetPy, we have come across a couple issues regarding case sensitivity. For example, we need to be able to parse
Meter
asmeter
andCelcius
as an alias ofdegrees_Celcius
. To enable this within Pint (as an option of course and not the default to maintain standards), I would like to propose the following to extend the case insensitive handling already existing in Pint:case_sensitive
option toBaseRegistry
which defaults toTrue
case_sensitive
options onget_name
,parse_unit_name
,parse_pattern
, andparse_expression
to default toNone
instead ofTrue
, and haveNone
be replaced within the methods with the registry'scase_sensitive
optioncase_sensitive
kwarg toparse_units
case_sensitive
kwarg to any other public registry method that ends up usingparse_unit_name
(or something that uses it, recursively) so that it can be appropriately passed along.This would allow something like the following to become valid, so that a greater extent of CF unit compliance can be achieved:
@hgrecco Is this compatible enough with your philosophy for Pint in #1081 (comment) and seem like a reasonable enough way forward in implementation?
The text was updated successfully, but these errors were encountered: