Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: add a section on NumPy's module structure to the refguide #25674

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 1 commit into from
Jan 25, 2024

Conversation

rgommers
Copy link
Member

@rgommers rgommers commented Jan 23, 2024

This addresses the main remaining item of NEP 52 - Python API cleanup for NumPy 2.0.

Most modules now have a reasonable page to land on with a full function/object listing of what's in their namespace. The exceptions are:

  • The main numpy namespace; that has always been done per topic - it'd be quite nice to also have a single page with everything in the namespace, but that's a fight with Sphinx that is not so easy to win. So leaving that for another time.
  • numpy.random: missing a function listing and the docs need more cleanup; that's a long-standing issue so also considering that out of scope here.
  • numpy.dtypes: this file was left out of a recent PR, @ngoldbaum said he would fix that this week.

Also incorporate a number of other fixes as I bumped into issues (Sphinx warnings, use of private namespaces in examples, missing page headers, etc.).

@ngoldbaum
Copy link
Member

Thanks for this Ralf!

The numpy.dtypes docs got merged along with #25656.

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Nice, just one point of confusion

@@ -23,7 +23,6 @@ indentation.
routines.bitwise
routines.char
routines.strings
routines.ctypeslib
Copy link
Contributor

Choose a reason for hiding this comment

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

Slightly confused why these are removed here.

Copy link
Member Author

Choose a reason for hiding this comment

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

This listing is by design an opinionated way of splitting up NumPy's main functionality into separate topics. Its coverage is incomplete for what's in the main namespace, and many more niche/legacy/deprecated topics and namespaces are not covered. So these edits make the listed topics more sensible. It's only a first cut with the most obvious changes that (to me) are really no-no's to list here. It does require further improvements (example: there are two string topics, and the one with the more general name points to numpy.char not numpy.strings).

As for the specific entries removed here:

  • ctypeslib: not relevant for 99.x% of users, so way too niche to list here - and now covered in the new module structure page
  • numpy.lib: that's simply not a coherent topic at all, so an entry for it does not make sense
  • routines.matlib: only contains a few functions and, more importantly, we're going to deprecate matrix usage and don't want any new code using it, so exposing this topic is not right anymore
  • testing.overrides: way too niche to list here, folded into the regular numpy.testing page

Note that this is the second iteration of editing this section (after gh-25650), and there'll be at least one more. Probably after exercising the .. legacy:: directive on a bunch of stuff.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, that makes sense. Resolved for me, but leaving it open for possible other reviewers, just because it is hard to understand why this was done in isolation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have now added a comment above this toctree for context, that should hopefully help keep things understandable and in better shape.

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -23,7 +23,6 @@ indentation.
routines.bitwise
routines.char
routines.strings
routines.ctypeslib
Copy link
Contributor

Choose a reason for hiding this comment

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

OK, that makes sense. Resolved for me, but leaving it open for possible other reviewers, just because it is hard to understand why this was done in isolation.

Also add some context to the "Routines and objects by topic" listing,
since that was helpful during PR review, and clean that up some more.

[skip cirrus] [skip azp]
@rgommers rgommers force-pushed the doc-module-structure branch from edb9563 to a33fc02 Compare January 25, 2024 09:53
@rgommers
Copy link
Member Author

This is good to go now.

@mattip mattip merged commit 578670b into numpy:main Jan 25, 2024
@mattip
Copy link
Member

mattip commented Jan 25, 2024

Thanks @rgommers

@rgommers rgommers deleted the doc-module-structure branch January 25, 2024 15:23
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.

4 participants