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

Logical indexing: Better error when Bool array index is wrong size #39261

Closed
BioTurboNick opened this issue Jan 14, 2021 · 1 comment
Closed

Comments

@BioTurboNick
Copy link
Contributor

Currently (1.5.3) if you try to access an array with a logical test of the wrong size, the error is:

[1;2;3][[true, false]]
ERROR: BoundsError: attempt to access 3-element Array{Int64,1} at index [Bool[1, 0]]

For small arrays, this may be clear enough. For larger arrays, much less clear.

Suggest something like:

ERROR: BoundsError: attempt to access 3-element Array{Int64,1} with mismatched Bool array of length 2.

I'm willing to do the PR if that seems okay.

@mbauman
Copy link
Sponsor Member

mbauman commented Jan 14, 2021

This has recently changed on master:

julia> [1;2;3][[true, false]]
ERROR: BoundsError: attempt to access 3-element Vector{Int64} at index [2-element Vector{Bool}]

This was #38689.

@mbauman mbauman closed this as completed Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants