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 float/rational/other number, or an IFDRational
:param denominator: Optional integer denominator :param denominator: Optional integer denominator
""" """
self._denominator = denominator if isinstance(value, IFDRational):
self._numerator = value self._numerator = value.numerator
self._val = float(1) self._denominator = value.denominator
self._val = value._val
return
if isinstance(value, Fraction): if isinstance(value, Fraction):
self._numerator = value.numerator self._numerator = value.numerator
self._denominator = value.denominator self._denominator = value.denominator
self._val = value else:
self._numerator = value
if isinstance(value, IFDRational): self._denominator = denominator
self._denominator = value.denominator
self._numerator = value.numerator
self._val = value._val
return
if denominator == 0: if denominator == 0:
self._val = float("nan") self._val = float("nan")
return
elif denominator == 1: elif denominator == 1:
self._val = Fraction(value) self._val = Fraction(value)
else: else: