Convert to float for comparison with float in IFDRational __eq__

This commit is contained in:
Andrew Murray 2021-04-17 15:39:42 +10:00
parent ef22a740eb
commit c04260b3f5
2 changed files with 6 additions and 1 deletions

View File

@ -28,6 +28,8 @@ def test_sanity():
_test_equal(1, 2, Fraction(1, 2))
_test_equal(1, 2, IFDRational(1, 2))
_test_equal(7, 5, 1.4)
def test_ranges():
for num in range(1, 10):

View File

@ -354,9 +354,12 @@ class IFDRational(Rational):
return self._val.__hash__()
def __eq__(self, other):
val = self._val
if isinstance(other, IFDRational):
other = other._val
return self._val == other
if isinstance(other, float):
val = float(val)
return val == other
def __getstate__(self):
return [self._val, self._numerator, self._denominator]