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

Doc: Add a single table as summary to math documentation #125810

Merged
merged 10 commits into from
Nov 1, 2024

Conversation

Nodd
Copy link
Contributor

@Nodd Nodd commented Oct 21, 2024

This is an draft for a table summary for the math module, as discussed in discourse. This is the version with a single table, with intermediate headers.

Direct link to the page preview

There is an alternative with multiple tables


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

@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news labels Oct 21, 2024
@Nodd Nodd changed the title Doc math monosummary Doc: Add a single table summary to math documentation Oct 21, 2024
@Nodd Nodd changed the title Doc: Add a single table summary to math documentation Doc: Add a single table as summary to math documentation Oct 21, 2024
Doc/library/math.rst Outdated Show resolved Hide resolved
@nedbat
Copy link
Member

nedbat commented Oct 22, 2024

Thanks for doing this, and linking directly to the preview.

I think the summary would be a little better if the arguments were shown, especially since sometimes a value mentioned in the summary is an argument, and sometimes a constant:

  • exp(x): e raised to the power of x
  • pow(x, y): x raised to the power of y

@Nodd
Copy link
Contributor Author

Nodd commented Oct 22, 2024

I thought about that too, and I even started to implement it. It looks indeed better, but it has to be done manually, so it's a bit tedious. If someone knows a better way than this:

:func:`pow(x, y) <pow>`

I'm all ears!

@merwok
Copy link
Member

merwok commented Oct 22, 2024

The parens are added by a sphinx setting (wrongly, I always thought, as func() is not the same as func or func(a, b) – with marked-up doc we don’t need the parens to signify that this is a function), so maybe there is another setting to show signatures? Then again maybe not, as signatures can be quite heavy with annotations…

@Nodd
Copy link
Contributor Author

Nodd commented Oct 22, 2024

I added the arguments. I choose to not mark default, positional-only nor keyword-only arguments in the table to keep it as light as possible.

@dg-pb
Copy link
Contributor

dg-pb commented Oct 23, 2024

👍

I like single table much more.
For me, multiple tables take more time to focus and find what I need.

FYI, There is an open PR for string methods: #1709

Doc/library/math.rst Outdated Show resolved Hide resolved
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@@ -26,6 +26,92 @@ The following functions are provided by this module. Except when explicitly
noted otherwise, all return values are floats.


==================================================== ============================================
**Number-theoretic and representation functions**
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be split out.

For some inspiration you could take look on the C17 and sections in the Annex F.10, e.g. here: https://en.cppreference.com/w/c/numeric/math. So, we should have something like 1) "Floating-point manipulation functions", 2) "Classification and comparison", 3) "Nearest integer operations", 4) "Basic operations" (maybe prod/fsum/etc - should be here).

Number-theoretic/combinatorial functions deserve a separate section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestion. I simply used the current organization of the page, and copied the existing section labels in the page. I think that reorganizing the whole page can be made in another PR, to focus this one on adding the table. I can do it afterwards.

Doc/library/math.rst Show resolved Hide resolved
Doc/library/math.rst Outdated Show resolved Hide resolved
@Nodd Nodd marked this pull request as ready for review October 24, 2024 19:15
Copy link
Contributor

@willingc willingc left a comment

Choose a reason for hiding this comment

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

This looks like a nice improvement to the docs as written. My recommendation would be to merge. If necessary, we can iterate on future PRs.

Thanks @Nodd for your first contribution 🎉

As an FYI, you can ask for folks to rereview here instead of discuss.python.org.

@Nodd
Copy link
Contributor Author

Nodd commented Oct 31, 2024

Thanks @willingc, I wasn't sure where was the best to ask for review. I'll keep it in mind for next time.

Copy link
Contributor

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

I saw that you were just re-using the same titles as the sections as well as their order so I think it's ok for this PR. However, in a follow-up PR we should address the following:

  • "Angular conversion" should be put before trigonometric functions so that trigonometric and hyperbolic ones are next to each other.
  • We should say "Power, exponential and logarithmic functions" and not just "Power and logarithmic functions" because exp(x) is not a power function per se.

@skirpichev
Copy link
Member

@picnixz, see also #125810 (comment)

@willingc
Copy link
Contributor

willingc commented Nov 1, 2024

Folks, I'm merging this as is. Future PRs can iterate on sections and wording. Thanks!

@willingc willingc added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Nov 1, 2024
@willingc willingc merged commit 74cf596 into python:main Nov 1, 2024
32 checks passed
@miss-islington-app
Copy link

Thanks @Nodd for the PR, and @willingc for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 1, 2024
…5810)

* Summary for math module with separate tables

* Forgot remainder description

* Single table

* data instead of func

* Add arguments in the table

* Fix inconsistencies in pow documentation

* Remove full stops from the table

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

* Fix math.pow link

* Fix spacing

---------

(cherry picked from commit 74cf596)

Co-authored-by: Joseph Martinot-Lagarde <contrebasse@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 1, 2024
…5810)

* Summary for math module with separate tables

* Forgot remainder description

* Single table

* data instead of func

* Add arguments in the table

* Fix inconsistencies in pow documentation

* Remove full stops from the table

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

* Fix math.pow link

* Fix spacing

---------

(cherry picked from commit 74cf596)

Co-authored-by: Joseph Martinot-Lagarde <contrebasse@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Nov 1, 2024

GH-126308 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Nov 1, 2024
@bedevere-app
Copy link

bedevere-app bot commented Nov 1, 2024

GH-126309 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Nov 1, 2024
willingc pushed a commit that referenced this pull request Nov 1, 2024
…25810) (GH-126308)

Doc: Add a single table as summary to math documentation (GH-125810)

* Summary for math module with separate tables

* Forgot remainder description

* Single table

* data instead of func

* Add arguments in the table

* Fix inconsistencies in pow documentation

* Remove full stops from the table



* Fix math.pow link

* Fix spacing

---------

(cherry picked from commit 74cf596)

Co-authored-by: Joseph Martinot-Lagarde <contrebasse@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
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 issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants