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

[NO ISSUE] Adds __eq__ support for non-normalized fractions #103959

Closed
wants to merge 1 commit into from
Closed

[NO ISSUE] Adds __eq__ support for non-normalized fractions #103959

wants to merge 1 commit into from

Conversation

nsbruce
Copy link

@nsbruce nsbruce commented Apr 27, 2023

If a fraction is created with the _normalize parameter set to false, it fill fail equality checks it should not.

For example before this fix: Fraction(4,2,_normalize=False) != 2.

This PR changes the equality check from just checking that the comparison int equals the numerator to checking that numerator/denominator is equal to the int.

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Apr 27, 2023

The following commit authors need to sign the Contributor License Agreement:

Click the button to sign:
CLA not signed

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@hauntsaninja
Copy link
Contributor

The _normalize parameter is meant for internal use only, as an optimisation for creating objects when we know the numerator and denominator are already normalised. Fraction does not support unnormalised fractions.

@hauntsaninja
Copy link
Contributor

In fact, looks like it was removed entirely in #101780

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.

3 participants