hgrecco / pint

Operate and manipulate physical quantities in Python
http://pint.readthedocs.org/
Other
2.41k stars 473 forks source link

Decimal option crashes Quantity constructor #2068

Open XZF0 opened 3 weeks ago

XZF0 commented 3 weeks ago
import pint
import decimal
ureg = pint.UnitRegistry(non_int_type=decimal.Decimal) 
y = ureg.Quantity('1.2345', 'm')
print(y.to('cm'))
#>>> TypeError: can't multiply sequence by non-int of type 'decimal.Decimal'

ureg = pint.UnitRegistry(non_int_type=decimal.Decimal) 
y = ureg.Quantity(1.2345, 'm')
print(y.to('cm'))
#>>> TypeError: unsupported operand type(s) for *: 'float' and 'decimal.Decimal'