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

Update docstring of getindex #38537

Merged
merged 2 commits into from
Dec 1, 2020
Merged

Update docstring of getindex #38537

merged 2 commits into from
Dec 1, 2020

Conversation

bkamins
Copy link
Member

@bkamins bkamins commented Nov 23, 2020

The current docstring suggests that only a limited range of inds are allowed, which is not the case.

The current docstring suggests that only a limited range of `inds` are allowed, which is not the case.
@dkarrasch dkarrasch added the domain:docs This change adds or pertains to documentation label Nov 23, 2020
Return a subset of array `A` as specified by `inds`, where each `ind` may be an
`Int`, an [`AbstractRange`](@ref), or a [`Vector`](@ref). See the manual section on
[array indexing](@ref man-array-indexing) for details.
Return a subset of array `A` as specified by `inds`, where each `ind` may be in
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't work gramatically. ind here is intended to refer to elements of the inds tuple, so the existing doc string is correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not correct. I understand that ind refers to elements of the tuple, but the point is that ind can take many different values (not necessarily "an Int, an AbstractRange, or a Vector"). Here is an example:

julia> x = [1 2; 3 4]
2×2 Array{Int64,2}:
 1  2
 3  4

julia> x[[1 2], view(y, 1), big(1)]
1×2 Array{Int64,2}:
 1  3

and as you can see:

  1. the first index passed is a Matrix (not listed)
  2. the second index passed is a 0-dimensional view (not listed)
  3. the third index is BigInt (not listed)

There are so many types of values that are allowed that I think it is not worth to list them here, but that is why I propose to add "in particular" in this docstring.

The issue is that this docstring is confusing to the users, as they think that only the three types listed in it are allowed, while this is not the case.

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 you want: "where each ind may be, for example,. ..."

Copy link
Member Author

Choose a reason for hiding this comment

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

changed

(for my learning as I am not a native speaker: I thought that in this context "in particular" and "for example" are synonymous - what is the difference in their meaning here?)

Thank you!

Copy link
Member

Choose a reason for hiding this comment

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

in particular is used for elaboration as in "Jupyter is an acronym. In particular, it was named after the languages Julia, Python and R" or specialization (to the exclusion of those not listed) as in "the Julia developers are really smart, Jeff Bezanson in particular" (implying that while everyone is smart, Jeff is even more so). However, it always needs to be preceded by a clause that it applies too, which is why the grammar didn't work here.

base/abstractarray.jl Outdated Show resolved Hide resolved
@fredrikekre fredrikekre merged commit b1adb5d into JuliaLang:master Dec 1, 2020
@bkamins bkamins deleted the patch-24 branch December 1, 2020 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants