Merge pull request #4105 from radarhere/ifd

IFDRational init cleanup
This commit is contained in:
Hugo van Kemenade 2019-11-13 20:30:35 +02:00 committed by GitHub
commit 3134e5cd47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -310,25 +310,21 @@ class IFDRational(Rational):
float/rational/other number, or an IFDRational
:param denominator: Optional integer denominator
"""
self._denominator = denominator
self._numerator = value
self._val = float(1)
if isinstance(value, IFDRational):
self._numerator = value.numerator
self._denominator = value.denominator
self._val = value._val
return
if isinstance(value, Fraction):
self._numerator = value.numerator
self._denominator = value.denominator
self._val = value
if isinstance(value, IFDRational):
self._denominator = value.denominator
self._numerator = value.numerator
self._val = value._val
return
else:
self._numerator = value
self._denominator = denominator
if denominator == 0:
self._val = float("nan")
return
elif denominator == 1:
self._val = Fraction(value)
else: