Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-122450: Indicate thatFraction denominators are always positive#136789

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AA-Turner merged 1 commit intopython:mainfromnacind:fractions_clarification
Jul 19, 2025

Conversation

nacind
Copy link
Contributor

@nacindnacind commentedJul 19, 2025
edited by github-actionsbot
Loading

In reference to#122450
Working on this at the EuroPython conference.


📚 Documentation preview 📚:https://cpython-previews--136789.org.readthedocs.build/

@python-cla-bot
Copy link

python-cla-botbot commentedJul 19, 2025
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

@@ -25,8 +25,8 @@ another rational number, or from a string.

The first version requires that *numerator* and *denominator* are instances
of:class:`numbers.Rational` and returns a new:class:`Fraction` instance
with value ``numerator/denominator``. If *denominator* is ``0``, it
raises a:exc:`ZeroDivisionError`.
with value equal to ``numerator/denominator`` where the denominator is positive.
Copy link
Contributor

@skirpichevskirpichevJul 19, 2025
edited
Loading

Choose a reason for hiding this comment

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

Sorry, I don't think it's an improvement.

Old sentence is clear: we return a rational number with value numerator/denominator.
But original numerator and denominator may have any sign, may be not integers, etc.

Choose a reason for hiding this comment

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

I agree with@skirpichev. We can leave "equals", but "where the denominator is positive" is incorrect or at least ambiguous. "Denominator" refers to the argument of theFraction constructor, not thedenominator property.

Copy link
Member

@picnixzpicnixzJul 19, 2025
edited
Loading

Choose a reason for hiding this comment

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

I also agree. It's as if we requiredenomintor to be positive (as an argument) which is not the case. So I suggest to revert this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I opened pr to fix docstrings in Rational class:#136800 It's a accompanying pr to#122464, which fix sphinx docs (and stuck in review).

But maybe it's ok to combine both and include reversion of this pr? All that only affects docs and IMO - fine for backporting up to 3.13.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

@serhiy-storchaka@skirpichev we discussed this at the sprint and decided that*denominator* (italics) referred to the argument, butdenominator (normal/roman) in the context of the sentence referred to the new argument. Regardless, it simplifies the arguments, so it is not always thedenominator argument that is set as the class attribute.

A

Choose a reason for hiding this comment

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

It says: "a new :class:Fraction instance with value equal tonumerator/denominator". "denominator" refers to argument, not to the property. Otherwise this sentence does not make sense. Then you say that in "where the denominator is positive" "denominator" refers to something other. But it clearly refers to the same thing as in previous expression. Your interpretation requires interpreting the same word in two different ways simultaneously. Even if it makes sense, it is very unclear and confusing. And to me, it just looks wrong.

@skirpichev
Copy link
Contributor

I suggest closing this pr.

Instead, as explained in the issue thread, we could document numerator/denominator properties of in the Rational class, i.e. add docstrings. Class description already says they are in lowest terms and denominator is positive.

@skirpichev
Copy link
Contributor

IMO, alternative pr#122464 is in a better shape.

@AA-TurnerAA-Turner changed the titlegh-122450: Now indicates that the resulting denominator will always be positive.gh-122450: Indicate thatFraction denominators are always positive.Jul 19, 2025
@AA-TurnerAA-Turner changed the titlegh-122450: Indicate thatFraction denominators are always positive.gh-122450: Indicate thatFraction denominators are always positiveJul 19, 2025
@AA-Turner
Copy link
Member

@skirpichev I'm mentoring this contribution in the EuroPython sprints, I think it's a good first step improvement.

A

@AA-TurnerAA-Turner added awaiting review needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes and removed awaiting merge labelsJul 19, 2025
@AA-TurnerAA-Turner merged commiteb8ac4c intopython:mainJul 19, 2025
45 checks passed
@github-project-automationgithub-project-automationbot moved this fromTodo toDone inDocs PRsJul 19, 2025
@miss-islington-app
Copy link

Thanks@nacind for the PR, and@AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJul 19, 2025
…itive (pythonGH-136789)(cherry picked from commit eb8ac4c85773160a6104abafdea9159f26363a9b)Co-authored-by: nacind <107233139+nacind@users.noreply.github.com>
@miss-islington-app
Copy link

Sorry,@nacind and@AA-Turner, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker eb8ac4c85773160a6104abafdea9159f26363a9b 3.13

@bedevere-app
Copy link

GH-136792 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJul 19, 2025
@skirpichev
Copy link
Contributor

skirpichev commentedJul 19, 2025
edited
Loading

@AA-Turner, sorry. I don't think so.

"with value equal tonumerator/denominator where the denominator is positive" - here "the denominator" is denominator of the Fraction instance or a parameter in it's constructor?

I would appreciate opinion of math's people ;-) CC@picnixz CC@serhiy-storchaka per experts index.

skirpichev added a commit to skirpichev/cpython that referenced this pull requestJul 19, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@skirpichevskirpichevskirpichev left review comments

@serhiy-storchakaserhiy-storchakaserhiy-storchaka left review comments

@AA-TurnerAA-TurnerAA-Turner approved these changes

@picnixzpicnixzpicnixz left review comments

Assignees

@AA-TurnerAA-Turner

Labels
docsDocumentation in the Doc dirneeds backport to 3.13bugs and security fixesskip newssprint
Projects
Status: Done
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@nacind@skirpichev@AA-Turner@serhiy-storchaka@picnixz

[8]ページ先頭

©2009-2025 Movatter.jp