diff options
author | Sergey B Kirpichev <skirpichev@gmail.com> | 2023-02-27 19:11:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-27 19:11:28 (GMT) |
commit | 4624987b296108c2dc1e6e3a24e65d2de7afd451 (patch) | |
tree | 0a490563b4c31f14740e72ce6b3ef0c0c1a3e2e8 /Lib/fractions.py | |
parent | 4f3786b7616dd464242b88ad6914053d409fe9d2 (diff) | |
download | cpython-4624987b296108c2dc1e6e3a24e65d2de7afd451.zip cpython-4624987b296108c2dc1e6e3a24e65d2de7afd451.tar.gz cpython-4624987b296108c2dc1e6e3a24e65d2de7afd451.tar.bz2 |
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>
Diffstat (limited to 'Lib/fractions.py')
-rw-r--r-- | Lib/fractions.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/fractions.py b/Lib/fractions.py index f718b35..c95db07 100644 --- a/Lib/fractions.py +++ b/Lib/fractions.py @@ -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) |