Fix summation of Decimal values
vrtulka23 opened this issue · 2 comments
vrtulka23 commented
Summation of quantities with Decimal magnitudes gives following error:
>>> Quantity(Decimal(2.34234923498499399204), 'cm') + Quantity(Decimal(23993.2340184099288340099), 'm')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/.local/lib/python3.10/site-packages/scinumtools/units/quantity.py", line 80, in __add__
return self._add(self, other)
File "/home/ubuntu/.local/lib/python3.10/site-packages/scinumtools/units/quantity.py", line 71, in _add
magnitude = c.add(left, right)
File "/home/ubuntu/.local/lib/python3.10/site-packages/scinumtools/units/unit_types.py", line 27, in add
return unit1.magnitude + unit2.to(unit1.baseunits).magnitude
File "/home/ubuntu/.local/lib/python3.10/site-packages/scinumtools/units/quantity.py", line 221, in to
self.magnitude = self._convert(self.magnitude, self.baseunits, baseunits)
File "/home/ubuntu/.local/lib/python3.10/site-packages/scinumtools/units/quantity.py", line 198, in _convert
return c.convert(magnitude1)
File "/home/ubuntu/.local/lib/python3.10/site-packages/scinumtools/units/unit_types.py", line 20, in convert
getattr(self, self.conversion[0])(magnitude1.value * self.baseunits1.magnitude, *self.conversion[1:]) / self.baseunits2.magnitude,
TypeError: unsupported operand type(s) for *: 'decimal.Decimal' and 'float'
vrtulka23 commented
fixed +, -, * and / operation
vrtulka23 commented
This was fixed in the recent commit.