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
Currently an order comparison (e.g., <) between a UnitScalar and a float returns a result based on the value for the UnitScalar. That comparison doesn't really quite make sense except in the case where the UnitScalar is actually unitless, and we end up with odd-looking situations like the following, where < doesn't give a partial order:
I'd suggest that the last two comparisons above should raise TypeError.
For comparison, we do get an exception (though not TypeError) when comparing incomparable UnitScalar objects:
Python 3.6.0 |Enthought, Inc. (x86_64)| (default, Mar 3 2017, 03:26:01)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from scimath.units.api import UnitScalar
>>> x = UnitScalar(3.2, units="kg")
>>> y = UnitScalar(2.3, units="m")
>>> x < y
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mdickinson/.edm/envs/test36/lib/python3.6/site-packages/scimath/units/unit_array.py", line 415, in __lt__
other, u = self.__convert_other(other)
File "/Users/mdickinson/.edm/envs/test36/lib/python3.6/site-packages/scimath/units/unit_array.py", line 247, in __convert_other
other = convert(numpy.array(other), ou, su)
File "/Users/mdickinson/.edm/envs/test36/lib/python3.6/site-packages/scimath/units/convert.py", line 102, in convert
raise ex
File "/Users/mdickinson/.edm/envs/test36/lib/python3.6/site-packages/scimath/units/convert.py", line 97, in convert
factor = float(from_unit / to_unit)
File "/Users/mdickinson/.edm/envs/test36/lib/python3.6/site-packages/scimath/units/unit.py", line 149, in __float__
raise InvalidConversion(self)
scimath.units.unit.InvalidConversion: dimensional quantities ('m*kg**-1') cannot be converted to scalars
The text was updated successfully, but these errors were encountered:
Currently an order comparison (e.g.,
<
) between aUnitScalar
and afloat
returns a result based on the value for theUnitScalar
. That comparison doesn't really quite make sense except in the case where theUnitScalar
is actually unitless, and we end up with odd-looking situations like the following, where<
doesn't give a partial order:I'd suggest that the last two comparisons above should raise
TypeError
.For comparison, we do get an exception (though not
TypeError
) when comparing incomparableUnitScalar
objects:The text was updated successfully, but these errors were encountered: