-
Notifications
You must be signed in to change notification settings - Fork 502
Closed
Labels
Description
I did not find any information on parsing strings in order to initiate a Measurement object in the pint documentation. The method described for the Quantity object shows an unwanted behaviour and creates a product if ± is used as separator between nominal value and uncertainty. In the case of +/-, a DefinitionSyntaxError is raised.
Example:
import pint
ureg = pint.UnitRegistry()
for item in ['123 g','123 ± 3 g', '123 +/- 3 g']:
print(ureg(item))
Output:
123 gram
369 gram
---------------------------------------------------------------------------
DefinitionSyntaxError Traceback (most recent call last)
Input In [2], in <module>
3 ureg = pint.UnitRegistry()
5 for item in ['123 g','123 ± 3 g', '123 +/- 3 g']:
----> 6 print(ureg(item))
...
DefinitionSyntaxError: missing unary operator "/"
I used version 0.20.1 of pint in the example.
Reactions are currently unavailable