gh-101825: Clarify that as_integer_ratio() output is always normalized (#101843)

Make docstrings for `as_integer_ratio` consistent across types, and document that
the returned pair is always normalized (coprime integers, with positive denominator).

---------

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
This commit is contained in:
Sergey B Kirpichev 2023-02-27 22:11:28 +03:00 committed by GitHub
parent 4f3786b761
commit 4624987b29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 27 deletions

View file

@ -331,10 +331,9 @@ class Fraction(numbers.Rational):
return self._denominator == 1
def as_integer_ratio(self):
"""Return the integer ratio as a tuple.
"""Return a pair of integers, whose ratio is equal to the original Fraction.
Return a tuple of two integers, whose ratio is equal to the
Fraction and with a positive denominator.
The ratio is in lowest terms and has a positive denominator.
"""
return (self._numerator, self._denominator)