forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inconsistant logical index behavior (JuliaLang#45869)
1. If we use `BitArray`/`Array{Bool}` to index, `to_indices` has an optimiztion for linear-iteratable case. But the corresponding check is not correct. IIUC, this optimization is legal only when the Boolen array is the only index provided. The first commit fix it and widen this optimization to all Boolen array. Before this PR ```julia julia> A = rand(2,3,4); I = rand(Bool,3,4); julia> A[1,I] == A[1,view(I,:,:)] ERROR: BoundsError: attempt to access 2×3×4 Array{Float64, 3} at index [1, 3×4 Matrix{Bool}] ``` After ```julia julia> A = rand(2,3,4); I = rand(Bool,3,4); julia> A[1,I] == A[1,view(I,:,:)] true ``` 2. On master, if the index/array has singleton trailing dimension, boundcheck of logical index show different behavior depending on the number of indexes provided. If there's only one index variable, singleton dimension wil not be ignored. The second commit fix it. (close JuliaLang#45867) --------- Co-authored-by: Matt Bauman <[email protected]>
- Loading branch information
Showing
5 changed files
with
139 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.