Skip to content

bpo-45584: Clarify the meaning of truncate in documentation #29183

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

Merged
merged 8 commits into from
Apr 2, 2022

Conversation

Arthur-Milchior
Copy link
Contributor

@Arthur-Milchior Arthur-Milchior commented Oct 23, 2021

bpo-45584: Clarify the meaning of truncate in documentation

While floor/ceil 's documentation are very precise, truncate was not explained. I actually had to search online to understand the difference between truncate and floor (admittedly, once I remembered that numbers are signed, and that floating numbers actually uses a bit for negation symbol instead of two complement, it became obvious)

I assume that I won't be the only user having this trouble, especially for people whose mother tongue is not English. So I suggest adding a clarification to help make what should be obvious to most actually explicit

https://bugs.python.org/issue45584

Copy link
Member

@merwok merwok left a comment

Choose a reason for hiding this comment

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

Not a math expert but the change makes sense to me!

:class:`~numbers.Integral` (usually an integer). Delegates to
:meth:`x.__trunc__() <object.__trunc__>`.
:class:`~numbers.Integral` (usually an integer). Truncating *x* means
removing the digits after the decimal comma, hence rounding toward 0. It is
Copy link
Contributor

Choose a reason for hiding this comment

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

Since not all locales use a comma:

Suggested change
removing the digits after the decimal comma, hence rounding toward 0. It is
removing the digits after the decimal separator, hence rounding toward 0. It is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.
I didn't realize that the English doc had to be normalized. I admit that if I were to translate it to French (my mother tongue), I clearly would have used "dot". But I guess it's great this way, thanks!

Not a math expert but the change makes sense to me!

Great! That's the point. That the doc is easy to get even without being a math expert. At least in my opinion.

While floor/ceil 's documentation are very precise, `truncate` was not explained. I actually had to search online to understand the difference between `truncate` and `floor` (admittedly, once I remembered that numbers are signed, and that floating numbers actually uses a bit for negation symbol instead of two complement, it became obvious)

I assume that I won't be the only user having this trouble, especially for people whose mother tongue is not English. So I suggest adding a clarification to help make what should be obvious to most actually explicit
@merwok
Copy link
Member

merwok commented Nov 1, 2021

For future PRs to CPython repositories, please avoid using rebases and force pushes: https://devguide.python.org/pullrequest/#quick-guide

@python python deleted a comment from the-knights-who-say-ni Nov 2, 2021
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@Arthur-Milchior
Copy link
Contributor Author

Azure pipelines PR fail at Pre-build check

stating

##[error]No hosted parallelism has been purchased or granted. To request a free parallelism grant, please fill out the following form https://aka.ms/azpipelines-parallelism-request

I assume it's unrelated to the current PR. What should I do here?

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be put in the comfy chair!

@terryjreedy
Copy link
Member

Azure Pipelines PR tests are currently not working, so that failure can be ignored. In essence, all checks are currently passing.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@Arthur-Milchior
Copy link
Contributor Author

I have made the requested changes; please review again.

I tested ceil and floor, they both link as expected.

Do you believe it would make sens to try to go over the whole

@bedevere-bot
Copy link

Thanks for making the requested changes!

@terryjreedy, @merwok: please review the changes made to this pull request.

Arthur-Milchior added a commit to Arthur-Milchior/cpython that referenced this pull request Nov 29, 2021
This commit is the first commit of what I plan to be a sequence of commit whose
goal is to improve the documentation usability. It's goal is to be an example,
concentrated on ``__name__``, that will allow me to get feedback and show my
goals before working on other missing references.

Whatever the place in the documentation, it may always save a little bit of time
that references are clicable. This allows the reader to easily get more
information if needed. My goal is to go through the part of the documentation in
/Doc and ensure that as many method, variable, members, functions,
classes... becomes links. Actually, I got the idea from PR python#29183, where
terryjreedy asked me to add a link to a method in a part of the documentation my
PR was touching. I believe the idea was good and should be systematized.

Since this may be a big change, here are the steps to ensure that it gets easy
to review:
* each commit consider a single word. In this case ``__name__``, so the commit
is really easy (even if boring) to review
* only the lines containing the changed words are changed. No other reformating
occurs. This allow any diff tool to really easily show that no other differences
are introduced.

The downside is that some lines are now longer than 80 characters. However, I
should note that this constraint was already not respected in a lot of place of
the documentation. And until there is an automated formatting tool, I think the
cost is quite small compared to the improvement in the documentation
usability. If those 80 characters are considered a blocker, it would be easy to
reformat all lines in a last commit, once the link creations are done.
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Looks good.

@terryjreedy your suggestions were addressed, are you OK with merging this now?

@terryjreedy
Copy link
Member

Please go ahead.

@JelleZijlstra JelleZijlstra merged commit ebbdbbf into python:main Apr 2, 2022
@miss-islington
Copy link
Contributor

Thanks @Arthur-Milchior for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry @Arthur-Milchior and @JelleZijlstra, I had trouble checking out the 3.10 backport branch.
Please backport using cherry_picker on command line.
cherry_picker ebbdbbff5d6840807e46ec61b8a323e94ee88de2 3.10

@bedevere-bot
Copy link

GH-32272 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Apr 2, 2022
@JelleZijlstra JelleZijlstra added needs backport to 3.10 only security fixes and removed needs backport to 3.10 only security fixes labels Apr 2, 2022
@miss-islington
Copy link
Contributor

Thanks @Arthur-Milchior for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Apr 2, 2022
@bedevere-bot
Copy link

GH-32273 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 2, 2022
While floor/ceil 's documentation are very precise, `truncate` was not explained. I actually had to search online to understand the difference between `truncate` and `floor` (admittedly, once I remembered that numbers are signed, and that floating numbers actually uses a bit for negation symbol instead of two complement, it became obvious)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Éric Araujo <merwok@netwok.org>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit ebbdbbf)

Co-authored-by: Arthur Milchior <arthur@milchior.fr>
miss-islington added a commit that referenced this pull request Apr 2, 2022
While floor/ceil 's documentation are very precise, `truncate` was not explained. I actually had to search online to understand the difference between `truncate` and `floor` (admittedly, once I remembered that numbers are signed, and that floating numbers actually uses a bit for negation symbol instead of two complement, it became obvious)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Éric Araujo <merwok@netwok.org>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit ebbdbbf)

Co-authored-by: Arthur Milchior <arthur@milchior.fr>
miss-islington added a commit that referenced this pull request Apr 2, 2022
While floor/ceil 's documentation are very precise, `truncate` was not explained. I actually had to search online to understand the difference between `truncate` and `floor` (admittedly, once I remembered that numbers are signed, and that floating numbers actually uses a bit for negation symbol instead of two complement, it became obvious)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Éric Araujo <merwok@netwok.org>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit ebbdbbf)

Co-authored-by: Arthur Milchior <arthur@milchior.fr>
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
While floor/ceil 's documentation are very precise, `truncate` was not explained. I actually had to search online to understand the difference between `truncate` and `floor` (admittedly, once I remembered that numbers are signed, and that floating numbers actually uses a bit for negation symbol instead of two complement, it became obvious)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Éric Araujo <merwok@netwok.org>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit ebbdbbf)

Co-authored-by: Arthur Milchior <arthur@milchior.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants