InvertedIndices.jl icon indicating copy to clipboard operation
InvertedIndices.jl copied to clipboard

Should InvertedIndices call `to_indices` on all elements in an array of skipped indices?

Open bkamins opened this issue 3 years ago • 3 comments

We have the following super bad behavior:

julia> [1, 2, 3, 4][Not(Not([1.5]))]
1-element Vector{Int64}:
 2

julia> [1, 2, 3, 4][Not(Not([1.5]))]
1-element Vector{Int64}:
 0

julia> [1, 2, 3, 4][Not(Not([1.5]))]
1-element Vector{Int64}:
 4294967297

which is a consequence of the fact that:

to_index(I::AbstractArray) = I

in Base.

@mbauman - do you think we should fix it in InvertedIndices.jl or this should be fixed in Base?

CC @nalimilan

bkamins avatar Jun 04 '22 19:06 bkamins

Another issue with Not:

julia> x = [1, 2, 3]
3-element Vector{Int64}:
 1
 2
 3

julia> x[Not(Integer[true, 2])]
1-element Vector{Int64}:
 3

and this should error

bkamins avatar Jun 05 '22 08:06 bkamins