# Selectdim fails to recognize IndexLinear

**URL:** https://discourse.julialang.org/t/selectdim-fails-to-recognize-indexlinear/10053
**Category:** Internals & Design
**Tags:** bug
**Created:** [March 29, 2018, 3:49pm UTC](https://discourse.julialang.org/t/selectdim-fails-to-recognize-indexlinear/10053 "2018-03-29T15:49:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cnliao](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@cnliao](https://discourse.julialang.org/u/cnliao)
#### Post date: [March 29, 2018, 3:49pm UTC](https://discourse.julialang.org/t/selectdim-fails-to-recognize-indexlinear/10053/1 "2018-03-29T15:49:24Z")

</div>

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
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

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

```

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

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [March 29, 2018, 8:01pm UTC](https://discourse.julialang.org/t/selectdim-fails-to-recognize-indexlinear/10053/2 "2018-03-29T20:01:34Z")

</div>

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

You might also be interested in [EllipsisNotation.jl](https://github.com/ChrisRackauckas/EllipsisNotation.jl).
