Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hauntsaninja
Copy link
Contributor

@hauntsaninja hauntsaninja commented Dec 24, 2022

@hauntsaninja
Copy link
Contributor Author

hauntsaninja commented Dec 24, 2022

The documentation guarantees that denominator is in lowest term. It doesn't make any explicit guarantee about being positive, but as_integer_ratio does and just returns the denominator. But do let me know if I should change to abs(self._denominator) == 1 or self._numerator % self._denominator == 0!

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

(But let's wait for Mark to also give feedback.)

Copy link
Member

@mdickinson mdickinson left a comment

LGTM; one reST markup nitpick.

@@ -117,6 +117,12 @@ another rational number, or from a string.

.. versionadded:: 3.8

.. method:: is_integer()

Return True if the Fraction is an integer.
Copy link
Member

@mdickinson mdickinson Dec 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: suggest inline code markup for True:

Suggested change
Return True if the Fraction is an integer.
Return ``True`` if the Fraction is an integer.

(We seem to be rather inconsistent about this across the codebase. The most authoritative source I could find is in the dev guide: https://devguide.python.org/documentation/markup/#quick-reference.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants