uncertainties
uncertainties copied to clipboard
Make `str_to_number_with_uncert()` locale-aware.
So, uncertainties currently cannot parse strings using decimal commas, such as 456,43 into the expected tuple, (456.43, 0.01). This is because the regex on line 2968 is too restrictive:
POSITIVE_DECIMAL_UNSIGNED_OR_NON_FINITE = r'((\d*)(\.\d*)?|nan|NAN|inf|INF)'
^--- only allows decimal point, not comma.
However, modifying this alone will cause the float() conversions to fail. There are two ways around it:
- use
locale.atof()instead, respecting the currently set locale - replace all commas for points and keep using
float()
I suppose doing it the first way (respecting locales) might be the "correct" way of doing it, but it might break things. It's what the current PR does. Please let me know if I should implement it the other way.
I'll then add tests.
Cheers!