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
importpintfromdecimalimportDecimalreg=pint.UnitRegistry(
auto_reduce_dimensions=True,
non_int_type=Decimal,
)
reg("km / h * m")
Resulting output is:
Traceback (most recent call last):
File "/path/to/my/pintrepro.py", line 10, in <module>
print(reg("km / h * m"))
^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/registry.py", line 1313, in parse_expression
return build_eval_tree(gen).evaluate(_define_op)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/pint_eval.py", line 146, in evaluate
return bin_op[op_text](
^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/quantity.py", line 998, in __mul__
return self._mul_div(other, operator.mul)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/quantity.py", line 100, in wrapped
return f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/quantity.py", line 83, in wrapped
result.ito_reduced_units()
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/qto.py", line 61, in ito_reduced_units
return quantity.ito(new_units)
^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/quantity.py", line 492, in ito
self._magnitude = self._convert_magnitude(other, *contexts, **ctx_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/quantity.py", line 469, in _convert_magnitude
return self._REGISTRY.convert(
^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/registry.py", line 965, in convert
return self._convert(value, src, dst, inplace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/context/registry.py", line 403, in _convert
return super()._convert(value, src, dst, inplace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/nonmultiplicative/registry.py", line 254, in _convert
return super()._convert(value, src, dst, inplace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/registry.py", line 999, in _convert
dst_dim = self._get_dimensionality(dst)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/registry.py", line 690, in _get_dimensionality
self._get_dimensionality_recurse(input_units, 1, accumulator)
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/registry.py", line 720, in _get_dimensionality_recurse
self._get_dimensionality_recurse(reg.reference, exp2, accumulator)
File "/path/to/my/venv/lib/python3.11/site-packages/pint/facets/plain/registry.py", line 708, in _get_dimensionality_recurse
exp2 = exp * ref[key]
~~~~^~~~~~~~~~
TypeError: unsupported operand type(s) for *: 'float' and 'decimal.Decimal'
Observed with the latest version of pint (0.22).
This doesn't get triggered by every formula, and I have not figured out the minimal necessary conditions to trigger the error. These examples result in the error:
km / h * m
kW / min * W
... but these do not:
m / h * m
km / s * m
m / h * m
The text was updated successfully, but these errors were encountered:
jonemo
added a commit
to jonemo/pint
that referenced
this issue
Sep 22, 2023
To reproduce run:
Resulting output is:
Observed with the latest version of pint (0.22).
This doesn't get triggered by every formula, and I have not figured out the minimal necessary conditions to trigger the error. These examples result in the error:
... but these do not:
The text was updated successfully, but these errors were encountered: