gh-100488: Add is_integer method to fractions.Fraction (#100489)

This commit is contained in:
Shantanu 2023-01-01 02:44:48 -06:00 committed by GitHub
parent 71159a8e07
commit e83f88a455
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 0 deletions

View file

@ -225,6 +225,10 @@ class Fraction(numbers.Rational):
(cls.__name__, dec, type(dec).__name__))
return cls(*dec.as_integer_ratio())
def is_integer(self):
"""Return True if the Fraction is an integer."""
return self._denominator == 1
def as_integer_ratio(self):
"""Return the integer ratio as a tuple.