Selectdim fails to recognize IndexLinear

bug

#1

I am on the latest master and wondering if the following behaviors considered bugs:

  • selectdim and view returns different types of SubArrays, which is surprising.
  • When N>2 the last type parameter of the returned SubArray is false even if the selection is on the last dimension of the Array. I doubt it will have performance inpact since IndexLinear is useful information for dispatch. Curiously when N=2 selectdim works just fine.
julia> VERSION
v"0.7.0-DEV.4719"
julia> x = fill(0., 2,2,2);
julia> typeof(selectdim(x,3,1))
SubArray{Float64,2,Array{Float64,3},Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Int64},false}
julia> typeof(view(x,:,:,1))
SubArray{Float64,2,Array{Float64,3},Tuple{Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}},Int64},true}

Currently for N-agnostic code I am using

view(x, Base.setindex(ntuple(i->Colon(), N),i,N)...)

But I suppose selectdim(x, N, i) is better style?


#2

Thanks for the report. I’ve filed a fix at https://github.com/JuliaLang/julia/pull/26655.

You might also be interested in EllipsisNotation.jl.