-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Implement S[I::AbstractVector{Bool}] and S[I::AbstractVector] for sparse X #7023
Comments
The mention of this issue in #7006 was done mistakenly and is unrelated. |
Indexing with boolean array fails unless it is of same size as the array. Is this what is desired? This is not the behavior in octave and matlab.
|
I think this is intentional and related to the "no recycling" rule. It could be added to the Noteworthy differences section of the manual for Matlab. For now it's explained in the R section in PR #6221:
|
...I'm not even sure what MATLAB's rule is here. Seems better to avoid this entirely.
|
Matlab's rule appears to be |
@tkelman ahh! I think |
Thanks. I think that's fair. Probably just needs a better mention in the array indexing section of the manual. |
Matlab's behavior in this example is consistent with the general indexing rule that a smaller array behaves as if it is zero-padded beyond its actual dimensions, and is allowed to grow by zero-padding if necessary. This specific case of logical indexing is documented here in the subsection "Logical Indexing with a Smaller Array". |
But I was not expecting MATLAB to columnize the matrix first. |
Matlab calls this linear indexing. It's not documented, but I believe Matlab resorts to linear indexing whenever ordinary indexing doesn't make sense. (Implicitly flattening the matrix is part of the attempt to apply linear indexing semantics.) The interaction of all of Matlab's indexing rules can be rather intricate to figure out. |
I know it's linear indexing. I've just never seen it do that with a logical index! (Or if I have, I filed it into the "don't ever do that again" category). At any rate, we seem to all agree it's not something we should emulate. Consider this horse thoroughly flogged. |
I know you know. It was more a comment for posterity. ;) |
#7047 closes this. The behaviour for logical indexing is the same as the dense case. |
Cc: @tanmaykm
The text was updated successfully, but these errors were encountered: