Skip to content

DOC: Rearranged parts of the Indexing docs to consolidate content #19407

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 7 commits into from
Aug 30, 2021

Conversation

Mukulikaa
Copy link
Contributor

Changes in Indexing in NumPy Fundamentals:

  1. Changed title from Indexing to Indexing basics.
  2. Removed all major content from sections: Assignment vs referencing, Single element indexing, Other indexing options, Index arrays, Indexing Multi-dimensional arrays, Boolean or “mask” index arrays, Combining index arrays with slices, Structural indexing tools, and added them to the Indexing doc in the reference guide.
  3. Kept very short overviews of the indexing options and cross-linked them to the Indexing doc in the reference guide.

Changes in Indexing in API Reference:

  1. Added information and examples from the basics doc (this required some subsections to be rearranged).
  2. Moved Detailed notes section to the end of the doc to maintain continuity.
  3. Added link to Indexing routines page

Closes #14038

Side note: I realize it's a huge PR and will potentially be difficult to review. Please let me know if there are better ways to go about these kinds of PRs that involve re-writes and changes to multiple files 🙂.

@Mukulikaa
Copy link
Contributor Author

The CI build is failing because of two reasons:

  1. I forgot to define a variable.

  2. It is failing the example of an error. I am not sure if we can skip certain code blocks during testing.

       >>> x = np.array([[1, 2], [3, 4], [5, 6]])
       >>> x[np.array([1, -1])]
       array([[3, 4],
             [5, 6]])
       >>> x[np.array([3, 4])]
       IndexError: index 3 is out of bounds for axis 0 with size 3`
    

@melissawm
Copy link
Member

Hi @Mukulikaa - sorry for the delay!

A couple of high-level comments:

  • I think the general idea of moving content from the user doc to the reference doc makes the user doc a little bit out of place as a "basics". In fact, reading it I kind of felt like it was way more advanced than the reference page, just because there are no examples and it is very abstract.
  • The original Indexing basics page kind of reads like a verbose how-to; I think it's useful for beginners to have that kind of entry-level content about indexing. Many people are coming from other programming languages and get tripped up on slicing, advanced indexing etc.
  • The original Indexing reference is to me very much an Explanation and, to me, should live in the Fundamentals section.
  • There are some indexing examples in Quickstart and the Absolute Beginners documents, but they are also mixed in with a lot of other stuff.

So, here's my suggestion (but others may very well disagree!):

  • Keep your edits to the doc/source/reference/arrays.indexing.rst document but move it to the fundamentals section;
  • Maybe merge the basics (doc/user/basics.indexing.rst) document into the arrays.indexing.rst document
  • Create an indexing how-to, with clear and concise examples of indexing operations.

Of course the how-to would come in another PR, but to me it makes more sense to organize things that way.

Thoughts?

cc @mattip @rossbar

@Mukulikaa
Copy link
Contributor Author

Thanks, @melissawm! I agree with all of your suggestions. I moved all the information to the reference guide doc because it was suggested here and I assumed users would prefer that. But I agree if we were to strictly follow Diataxis then we should move the doc to the Fundamentals.

I am also in the process of making a list of use-cases for the how-to 🙂.

@melissawm
Copy link
Member

So, right now here's what we have:

I'm wondering if it would just be better to remove the Indexing arrays section in the "N-dimensional array" page, and put that sentence directly into Indexing.

Another option would be to lose the Indexing page altogether; I'm struggling to understand if this is needed after the current changes.

Oh and another point: the "Indexing basics" page is not basic at all :) I'd change its title to Indexing or "Indexing on ndarrays", something like this.

@Mukulikaa
Copy link
Contributor Author

Another option would be to lose the Indexing page altogether; I'm struggling to understand if this is needed after the current changes.

I was also thinking about this because I agree that this doc is a stub. However, I felt that having that doc clearly visible in the sidebar makes it more accessible to someone who directly refers to the reference doc instead of the user guide (experienced users maybe?). So I was thinking if we could replace the stub with Indexing routines which would link to the doc in the user guide. It will look something like the ufuncs reference doc I restructured recently.

I'd change its title to Indexing or "Indexing on ndarrays", something like this.

I agree, we can change it to "Indexing on ndarrays" to avoid any clash.

I'm wondering if it would just be better to remove the Indexing arrays section in the "N-dimensional array" page, and put that sentence directly into Indexing.

I don't have any particular opinion on this so I'm happy to amend it the way everyone thinks is best!

@Mukulikaa
Copy link
Contributor Author

I am not sure if the CI failure is unrelated.

@mattip
Copy link
Member

mattip commented Aug 18, 2021

This is fixed on main but unfortunately circleCI does not "merge-from-main" before building a PR. So you will have to get those changes into this PR manually. I would recommend rebasing the PR on top of main, you could also merge main into the PR. A rebase would look like

git checkout main
git pull
git checkout indexing-docs-merge
git rebase
# if there are conflicts, you need to do some cycles of 
# git status
# <see what has conflicts>
# fix the file: look for sections with "<<<<", "=====", ">>>>>" and resolve the conflicts
# git add <file>
# git rebase --continue
git push -f Mukulikaa

@Mukulikaa Mukulikaa force-pushed the indexing-docs-merge branch from 630f910 to a3c72d6 Compare August 18, 2021 16:44
@Mukulikaa
Copy link
Contributor Author

Here is the rendered page.

@mattip
Copy link
Member

mattip commented Aug 18, 2021

Hmm, I started going through the content, but on second thought maybe that should be left for a follow-on PR. This does such a great job moving the pieces around it would be a shame to delay merging it on smaller details.

@Mukulikaa
Copy link
Contributor Author

If it is easier to leave comments on this PR for the changes required, I am happy to continue the work on this PR itself. As I am actively working on this it wouldn't cause much delay I think. 🙂

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

This is really impressive work @Mukulikaa , distilling the disparate info from these (heavily overlapping) documents is no small feat! I reviewed this with my main goal being to check that all of the relevant information from the two original documents (ref guide article & user guide article. For the most part I think this is satisfied - there were a few places where I thought some text/examples from one or the other document that had been dropped should be reincluded.

The only main thing that jumped out to me was the expansion of indexing types to include "single element indexing" as a top-level category. As mentioned in the specific comments, this should be folded under the "basic" indexing category. This was the only necessary change though IMO, everything else is either opinions or nits. Thanks for the excellent work here!

@Mukulikaa
Copy link
Contributor Author

Thank you for your comments @rossbar! I think I omitted some examples to reduce the length of the document but I agree that they should be included if they make the concepts clearer.

@Mukulikaa
Copy link
Contributor Author

Hi @rossbar, I've tried to incorporate the changes you suggested. Let me know if there are any other suggestions!

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Thanks for the iteration @Mukulikaa , you've addressed all my original comments very well - just a few more things I noticed in the updated text but otherwise this looks good to me. Excellent work!

Comment on lines 32 to 35
.. _basic-slicing-and-indexing:

Basic slicing and indexing
--------------------------
Copy link
Contributor

Choose a reason for hiding this comment

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

I would also vote to call this section Basic Indexing - as mentioned, slices fall under the "basic indexing" term. Renaming the link target assumes that there isn't already a .. _basic-indexing target defined elsewhere :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It hasn't been used anywhere else so I'll go ahead and change it.

Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
@@ -29,9 +29,9 @@ Note that in Python, ``x[(exp1, exp2, ..., expN)]`` is equivalent to
for the former.


.. _basic-slicing-and-indexing:
.. _basic-indexing:
Copy link
Member

Choose a reason for hiding this comment

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

This link may be in use by others outside NumPy. Could we leave both forms with a comment "legacy link name"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this link in this PR itself in a previous commit because I needed it for the stub Indexing doc that was left behind in the reference guide. Since then I removed the stub completely but forgot to remove this link... So should I just remove this link altogether?

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, I see. If it is new and no-one needs it then it can be removed.

@mattip
Copy link
Member

mattip commented Aug 29, 2021

The latest commit which changed a link name made me start thinking about a side-effect of this refactoring: it might break existing links. I took a look at the nitpicky CI run results for internal consistenc. It seems the WARNINGS: with the word "index" in them (like the See Also section of expand_dims and missing numpy.lib.index_tricks in the second paragraph of np.choose) existed before this PR and no new ones appeared. But there may be content out there that does rely on the older links. Should we make an effort to preserve them where possible?

@mattip mattip merged commit 7028aec into numpy:main Aug 30, 2021
@mattip
Copy link
Member

mattip commented Aug 30, 2021

Thanks @Mukulikaa. Let's put this in, we can make more changes if it turns out we broke links by rearranging things.

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.

DOC: Merge two indexing documentation pages
4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy