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

WIP/RFH: Deprecate generalized linear indexing #20040

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 56 additions & 97 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -829,65 +829,65 @@ error_if_canonical_indexing(::LinearIndexing, ::AbstractArray, ::Any...) = nothi
_getindex(::LinearIndexing, A::AbstractArray, I...) = error("indexing $(typeof(A)) with types $(typeof(I)) is not supported")

## LinearFast Scalar indexing: canonical method is one Int
_getindex(::LinearFast, A::AbstractVector, i::Int) = (@_propagate_inbounds_meta; getindex(A, i))
_getindex(::LinearFast, A::AbstractArray, i::Int) = (@_propagate_inbounds_meta; getindex(A, i))
_getindex{T}(::LinearFast, A::AbstractArray{T,0}) = A[1]
function _getindex{T,N}(::LinearFast, A::AbstractArray{T,N}, I::Vararg{Int,N})
# We must check bounds for sub2ind; so we can then use @inbounds
_getindex(::LinearFast, A::AbstractArray, i::Int) = (@_propagate_inbounds_meta; getindex(A, i))
_getindex(::LinearFast, A::AbstractArray) = (@_propagate_inbounds_meta; getindex(A, _to_linear_index(A)))
function _getindex(::LinearFast, A::AbstractArray, I::Int...)
@_inline_meta
@boundscheck checkbounds(A, I...)
@inbounds r = getindex(A, sub2ind(A, I...))
@boundscheck checkbounds(A, I...) # generally _to_linear_index requires bounds checking
@inbounds r = getindex(A, _to_linear_index(A, I...))
r
end
function _getindex(::LinearFast, A::AbstractVector, I1::Int, I::Int...)
@_inline_meta
@boundscheck checkbounds(A, I1, I...)
@inbounds r = getindex(A, I1)
r
######################### TODO: MOVE TO DEPRECATED.JL #########################
function _to_linear_index(A::AbstractArray)
depwarn("general linear indexing is deprecated; use reshape(A, Val{0}) before indexing", (:getindex, :setindex!, :view))
1
end
function _getindex(::LinearFast, A::AbstractArray, I::Int...) # TODO: DEPRECATE FOR #14770
@_inline_meta
@boundscheck checkbounds(A, I...)
@inbounds r = getindex(A, sub2ind(A, I...))
r
function _to_linear_index(A::AbstractArray, I::Int...)
depwarn("general linear indexing is deprecated; use reshape(A, Val{$(length(I))}) before indexing", (:getindex, :setindex!, :view))
sub2ind(A, I...)
end

function _to_linear_index(A::AbstractArray, i::Int, I::Int...)
depwarn("general linear indexing is deprecated; use reshape(A, Val{$(length(I))}) before indexing", (:getindex, :setindex!, :view))
i
end
###############################################################################
_to_linear_index(A::AbstractArray, i::Int) = i
_to_linear_index{T,N}(A::AbstractArray{T,N}, I::Vararg{Int,N}) = (@_inline_meta; sub2ind(A, I...))

## LinearSlow Scalar indexing: Canonical method is full dimensionality of Ints
_getindex{T,N}(::LinearSlow, A::AbstractArray{T,N}, I::Vararg{Int, N}) = (@_propagate_inbounds_meta; getindex(A, I...))
function _getindex(::LinearSlow, A::AbstractArray, i::Int)
# ind2sub requires all dimensions to be > 0; may as well just check bounds
_getindex(::LinearSlow, A::AbstractArray) = (@_propagate_inbounds_meta; getindex(A, _to_subscript_indices(A)...))
function _getindex(::LinearSlow, A::AbstractArray, I::Int...)
@_inline_meta
@boundscheck checkbounds(A, i)
@inbounds r = getindex(A, ind2sub(A, i)...)
@boundscheck checkbounds(A, I...) # generally _to_subscript_indices requires bounds checking
@inbounds r = getindex(A, _to_subscript_indices(A, I...)...)
r
end
@generated function _getindex{T,AN}(::LinearSlow, A::AbstractArray{T,AN}, I::Int...) # TODO: DEPRECATE FOR #14770
N = length(I)
if N > AN
# Drop trailing ones
Isplat = Expr[:(I[$d]) for d = 1:AN]
Osplat = Expr[:(I[$d] == 1) for d = AN+1:N]
quote
@_propagate_inbounds_meta
@boundscheck (&)($(Osplat...)) || throw_boundserror(A, I)
getindex(A, $(Isplat...))
end
else
# Expand the last index into the appropriate number of indices
Isplat = Expr[:(I[$d]) for d = 1:N-1]
sz = Expr(:tuple)
sz.args = Expr[:(size(A, $d)) for d=max(N,1):AN]
szcheck = Expr[:(size(A, $d) > 0) for d=max(N,1):AN]
last_idx = N > 0 ? :(I[$N]) : 1
quote
# ind2sub requires all dimensions to be > 0:
@_propagate_inbounds_meta
@boundscheck (&)($(szcheck...)) || throw_boundserror(A, I)
getindex(A, $(Isplat...), ind2sub($sz, $last_idx)...)
end
end
end
_getindex{T,N}(::LinearSlow, A::AbstractArray{T,N}, I::Vararg{Int, N}) = (@_propagate_inbounds_meta; getindex(A, I...))

######################### TODO: MOVE TO DEPRECATED.JL #########################
function _to_subscript_indices{T,N}(A::AbstractArray{T,N})
depwarn("general linear indexing is deprecated; use reshape(A, Val{0}) before indexing", (:getindex, :setindex!, :view))
fill_to_length((), 1, Val{N})
end
_to_subscript_indices{T}(A::AbstractArray{T,0}) = () # Ambiguity
_to_subscript_indices{T}(A::AbstractArray{T,0}, i::Int) = () # Ambiguity
function _to_subscript_indices{T}(A::AbstractArray{T,0}, I::Int...)
depwarn("general linear indexing is deprecated; use reshape(A, Val{$(length(I))}) before indexing", (:getindex, :setindex!, :view))
()
end
function _to_subscript_indices{T,N}(A::AbstractArray{T,N}, I::Int...)
depwarn("general linear indexing is deprecated; use reshape(A, Val{$(length(I))}) before indexing", (:getindex, :setindex!, :view))
J, _ = IteratorsMD.split(I, Val{N}) # (maybe) drop any trailing indices
sz = _remaining_size(J, size(A)) # compute trailing size (overlapping the final index)
(front(J)..., _unsafe_ind2sub(sz, last(J))...) # (maybe) extend the last index
end
_remaining_size(::Tuple{Any}, t::Tuple) = t
_remaining_size(h::Tuple, t::Tuple) = (@_inline_meta; _remaining_size(tail(h), tail(t)))
###############################################################################
_to_subscript_indices(A::AbstractArray, i::Int) = (@_inline_meta; _unsafe_ind2sub(A, i))
_to_subscript_indices{T,N}(A::AbstractArray{T,N}, I::Vararg{Int,N}) = I
_unsafe_ind2sub(::Tuple{}, i) = () # ind2sub may throw(BoundsError()) in this case
_unsafe_ind2sub(sz, i) = (@_inline_meta; ind2sub(sz, i))

## Setindex! is defined similarly. We first dispatch to an internal _setindex!
# function that allows dispatch on array storage
Expand All @@ -905,65 +905,24 @@ end
_setindex!(::LinearIndexing, A::AbstractArray, v, I...) = error("indexing $(typeof(A)) with types $(typeof(I)) is not supported")

## LinearFast Scalar indexing
_setindex!(::LinearFast, A::AbstractVector, v, i::Int) = (@_propagate_inbounds_meta; setindex!(A, v, i))
_setindex!(::LinearFast, A::AbstractArray, v, i::Int) = (@_propagate_inbounds_meta; setindex!(A, v, i))
_setindex!{T}(::LinearFast, A::AbstractArray{T,0}, v) = (@_propagate_inbounds_meta; setindex!(A, v, 1))
function _setindex!{T,N}(::LinearFast, A::AbstractArray{T,N}, v, I::Vararg{Int,N})
# We must check bounds for sub2ind; so we can then use @inbounds
@_inline_meta
@boundscheck checkbounds(A, I...)
@inbounds r = setindex!(A, v, sub2ind(A, I...))
r
end
function _setindex!(::LinearFast, A::AbstractVector, v, I1::Int, I::Int...)
@_inline_meta
@boundscheck checkbounds(A, I1, I...)
@inbounds r = setindex!(A, v, I1)
r
end
function _setindex!(::LinearFast, A::AbstractArray, v, I::Int...) # TODO: DEPRECATE FOR #14770
_setindex!(::LinearFast, A::AbstractArray, v) = (@_propagate_inbounds_meta; setindex!(A, v, _to_linear_index(A)))
function _setindex!(::LinearFast, A::AbstractArray, v, I::Int...)
@_inline_meta
@boundscheck checkbounds(A, I...)
@inbounds r = setindex!(A, v, sub2ind(A, I...))
@inbounds r = setindex!(A, v, _to_linear_index(A, I...))
r
end

# LinearSlow Scalar indexing
_setindex!{T,N}(::LinearSlow, A::AbstractArray{T,N}, v, I::Vararg{Int, N}) = (@_propagate_inbounds_meta; setindex!(A, v, I...))
function _setindex!(::LinearSlow, A::AbstractArray, v, i::Int)
# ind2sub requires all dimensions to be > 0; may as well just check bounds
_setindex!(::LinearSlow, A::AbstractArray, v) = (@_propagate_inbounds_meta; setindex!(A, v, _to_subscript_indices(A)...))
function _setindex!(::LinearSlow, A::AbstractArray, v, I::Int...)
@_inline_meta
@boundscheck checkbounds(A, i)
@inbounds r = setindex!(A, v, ind2sub(A, i)...)
@boundscheck checkbounds(A, I...)
@inbounds r = setindex!(A, v, _to_subscript_indices(A, I...)...)
r
end
@generated function _setindex!{T,AN}(::LinearSlow, A::AbstractArray{T,AN}, v, I::Int...) # TODO: DEPRECATE FOR #14770
N = length(I)
if N > AN
# Drop trailing ones
Isplat = Expr[:(I[$d]) for d = 1:AN]
Osplat = Expr[:(I[$d] == 1) for d = AN+1:N]
quote
# We only check the trailing ones, so just propagate @inbounds state
@_propagate_inbounds_meta
@boundscheck (&)($(Osplat...)) || throw_boundserror(A, I)
setindex!(A, v, $(Isplat...))
end
else
# Expand the last index into the appropriate number of indices
Isplat = Expr[:(I[$d]) for d = 1:N-1]
sz = Expr(:tuple)
sz.args = Expr[:(size(A, $d)) for d=max(N,1):AN]
szcheck = Expr[:(size(A, $d) > 0) for d=max(N,1):AN]
last_idx = N > 0 ? :(I[$N]) : 1
quote
# ind2sub requires all dimensions to be > 0:
@_propagate_inbounds_meta
@boundscheck (&)($(szcheck...)) || throw_boundserror(A, I)
setindex!(A, v, $(Isplat...), ind2sub($sz, $last_idx)...)
end
end
end

## get (getindex with a default value) ##

Expand Down
19 changes: 14 additions & 5 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,10 @@ done(a::Array,i) = (@_inline_meta; i == length(a)+1)

## Indexing: getindex ##

# This is more complicated than it needs to be in order to get Win64 through bootstrap
getindex(A::Array, i1::Int) = arrayref(A, i1)
getindex(A::Array, i1::Int, i2::Int, I::Int...) = (@_inline_meta; arrayref(A, i1, i2, I...)) # TODO: REMOVE FOR #14770
getindex{T}(A::Array{T,1}, i1::Int) = arrayref(A, i1)
getindex{T,N}(A::Array{T,N}, I::Vararg{Int,N}) = (@_inline_meta; arrayref(A, I...))
getindex{T}(A::Array{T,0}) = (@_inline_meta; arrayref(A, 1))

# Faster contiguous indexing using copy! for UnitRange and Colon
function getindex(A::Array, I::UnitRange{Int})
Expand Down Expand Up @@ -477,8 +478,15 @@ function getindex{S}(A::Array{S}, I::Range{Int})
end

## Indexing: setindex! ##
setindex!{T}(A::Array{T}, x, i1::Int) = arrayset(A, convert(T,x)::T, i1)
setindex!{T}(A::Array{T}, x, i1::Int, i2::Int, I::Int...) = (@_inline_meta; arrayset(A, convert(T,x)::T, i1, i2, I...)) # TODO: REMOVE FOR #14770
setindex!{T}(A::Array{T}, x, i::Int) = arrayset(A, convert(T,x)::T, i)
setindex!{T}(A::Array{T,1}, x, i::Int) = arrayset(A, convert(T,x)::T, i)
setindex!{T,N}(A::Array{T,N}, x, I::Vararg{Int,N}) = (@_inline_meta; arrayset(A, convert(T,x)::T, I...))
setindex!{T}(A::Array{T,0}, x) = (@_inline_meta; arrayset(A, convert(T,x)::T, 1))

# These are needed for ambiguity with a method in essentials.jl for bootstrap
setindex!(A::Array{Any,1}, x::ANY, i::Int) = arrayset(A, x, i)
setindex!(A::Array{Any,0}, x::ANY) = arrayset(A, x, 1)
setindex!{N}(A::Array{Any,N}, x::ANY, I::Vararg{Int,N}) = arrayset(A, x, I...)

# These are redundant with the abstract fallbacks but needed for bootstrap
function setindex!(A::Array, x, I::AbstractVector{Int})
Expand Down Expand Up @@ -525,7 +533,8 @@ function setindex!{T}(A::Array{T}, X::Array{T}, c::Colon)
end

setindex!(A::Array, x::Number, ::Colon) = fill!(A, x)
setindex!{T, N}(A::Array{T, N}, x::Number, ::Vararg{Colon, N}) = fill!(A, x)
# This causes a ton of ambiguities
# setindex!{T, N}(A::Array{T, N}, x::Number, ::Vararg{Colon, N}) = fill!(A, x)

# efficiently grow an array

Expand Down
22 changes: 20 additions & 2 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ function depwarn(msg, funcsym)
nothing
end

function firstcaller(bt::Array{Ptr{Void},1}, funcsym::Symbol)
firstcaller(bt::Array{Ptr{Void},1}, funcsym::Symbol) = firstcaller(bt, (funcsym,))
function firstcaller(bt::Array{Ptr{Void},1}, funcsyms)
# Identify the calling line
i = 1
while i <= length(bt)
Expand All @@ -83,7 +84,7 @@ function firstcaller(bt::Array{Ptr{Void},1}, funcsym::Symbol)
if lkup === StackTraces.UNKNOWN
continue
end
if lkup.func == funcsym
if lkup.func in funcsyms
@goto found
end
end
Expand Down Expand Up @@ -1425,6 +1426,23 @@ function promote_array_type(F, R, S, T)
_promote_array_type(F, R, S, T)
end

# Deprecate generalized linear indexing
function __maybe_reshape{N}(::LinearSlow, A::AbstractArray, ::NTuple{N})
depwarn("general linear indexing is deprecated; use reshape(A, Val{$N}) before indexing", (:getindex, :setindex!, :view))
reshape(A, Val{N})
end
function __maybe_reshape{N}(::LinearFast, A::AbstractArray, ::NTuple{N})
depwarn("general linear indexing is deprecated; use reshape(A, Val{$N}) before indexing", (:getindex, :setindex!, :view))
reshape(A, Val{N}) # Reshape isn't necessary, but do so to prevent depwarns everywhere
end
@inline __maybe_reshape{T,N}(::LinearFast, A::AbstractArray{T,N}, ::NTuple{N}) = A
@inline __maybe_reshape{T,N}(::LinearFast, A::AbstractArray{T,N}, ::NTuple{1}) = A
function _maybe_reshape_parent{N}(A::AbstractArray, ::NTuple{N, Bool})
depwarn("general linear indexing is deprecated; use reshape(A, Val{$N}) before indexing", (:getindex, :setindex!, :view))
reshape(A, Val{N})
end


# Deprecate manually vectorized abs2 methods in favor of compact broadcast syntax
@deprecate abs2(x::AbstractSparseVector) abs2.(x)

Expand Down
21 changes: 12 additions & 9 deletions base/linalg/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1547,12 +1547,11 @@ for (f, g) in ((:A_mul_Bc, :A_mul_Bc!), (:A_mul_Bt, :A_mul_Bt!))
end
end

for mat in (:AbstractVector, :AbstractMatrix)

### Multiplication with triangle to the left and hence rhs cannot be transposed.
for (f, g) in ((:*, :A_mul_B!), (:Ac_mul_B, :Ac_mul_B!), (:At_mul_B, :At_mul_B!))
@eval begin
function ($f)(A::AbstractTriangular, B::$mat)
($f)(A::AbstractTriangular, B::AbstractVector) = ($f)(A, reshape(B, Val{2}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read this correctly, I believe this changes the behavior such that the rhs is now promoted to a matrix, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Echoing @andreasnoack, these changes result in a matrix being returned rather than a vector, e.g.

julia> UpperTriangular(rand(3, 3)) * rand(3)
3×1 Array{Float64,2}:
 0.978125
 0.687285
 0.568977

Best!

function ($f)(A::AbstractTriangular, B::AbstractMatrix)
TAB = typeof(zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))
BB = similar(B, TAB, size(B))
copy!(BB, B)
Expand All @@ -1563,7 +1562,8 @@ end
### Left division with triangle to the left hence rhs cannot be transposed. No quotients.
for (f, g) in ((:\, :A_ldiv_B!), (:Ac_ldiv_B, :Ac_ldiv_B!), (:At_ldiv_B, :At_ldiv_B!))
@eval begin
function ($f)(A::Union{UnitUpperTriangular,UnitLowerTriangular}, B::$mat)
($f)(A::Union{UnitUpperTriangular,UnitLowerTriangular}, B::AbstractVector) = ($f)(A, reshape(B, Val{2}))
function ($f)(A::Union{UnitUpperTriangular,UnitLowerTriangular}, B::AbstractMatrix)
TAB = typeof(zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))
BB = similar(B, TAB, size(B))
copy!(BB, B)
Expand All @@ -1574,7 +1574,8 @@ end
### Left division with triangle to the left hence rhs cannot be transposed. Quotients.
for (f, g) in ((:\, :A_ldiv_B!), (:Ac_ldiv_B, :Ac_ldiv_B!), (:At_ldiv_B, :At_ldiv_B!))
@eval begin
function ($f)(A::Union{UpperTriangular,LowerTriangular}, B::$mat)
($f)(A::Union{UpperTriangular,LowerTriangular}, B::AbstractVector) = ($f)(A, reshape(B, Val{2}))
function ($f)(A::Union{UpperTriangular,LowerTriangular}, B::AbstractMatrix)
TAB = typeof((zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))/one(eltype(A)))
BB = similar(B, TAB, size(B))
copy!(BB, B)
Expand All @@ -1585,7 +1586,8 @@ end
### Multiplication with triangle to the rigth and hence lhs cannot be transposed.
for (f, g) in ((:*, :A_mul_B!), (:A_mul_Bc, :A_mul_Bc!), (:A_mul_Bt, :A_mul_Bt!))
@eval begin
function ($f)(A::$mat, B::AbstractTriangular)
($f)(A::AbstractVector, B::AbstractTriangular) = ($f)(reshape(A, Val{2}), B)
function ($f)(A::AbstractMatrix, B::AbstractTriangular)
TAB = typeof(zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))
AA = similar(A, TAB, size(A))
copy!(AA, A)
Expand All @@ -1596,7 +1598,8 @@ end
### Right division with triangle to the right hence lhs cannot be transposed. No quotients.
for (f, g) in ((:/, :A_rdiv_B!), (:A_rdiv_Bc, :A_rdiv_Bc!), (:A_rdiv_Bt, :A_rdiv_Bt!))
@eval begin
function ($f)(A::$mat, B::Union{UnitUpperTriangular, UnitLowerTriangular})
($f)(A::AbstractVector, B::Union{UnitUpperTriangular, UnitLowerTriangular}) = ($f)(reshape(A, Val{2}), B)
function ($f)(A::AbstractMatrix, B::Union{UnitUpperTriangular, UnitLowerTriangular})
TAB = typeof(zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))
AA = similar(A, TAB, size(A))
copy!(AA, A)
Expand All @@ -1608,15 +1611,15 @@ end
### Right division with triangle to the right hence lhs cannot be transposed. Quotients.
for (f, g) in ((:/, :A_rdiv_B!), (:A_rdiv_Bc, :A_rdiv_Bc!), (:A_rdiv_Bt, :A_rdiv_Bt!))
@eval begin
function ($f)(A::$mat, B::Union{UpperTriangular,LowerTriangular})
($f)(A::AbstractVector, B::Union{UpperTriangular,LowerTriangular}) = ($f)(reshape(A, Val{2}), B)
function ($f)(A::AbstractMatrix, B::Union{UpperTriangular,LowerTriangular})
TAB = typeof((zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))/one(eltype(A)))
AA = similar(A, TAB, size(A))
copy!(AA, A)
($g)(AA, convert(AbstractArray{TAB}, B))
end
end
end
end

# If these are not defined, they will fallback to the versions in matmul.jl
# and dispatch to generic_matmatmul! which is very costly to compile. The methods
Expand Down
14 changes: 9 additions & 5 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ using .IteratorsMD
A[to_indices(A, (i1, I...))...]
@propagate_inbounds setindex!(A::Array, v, i1::Union{Integer, CartesianIndex}, I::Union{Integer, CartesianIndex}...) =
(A[to_indices(A, (i1, I...))...] = v; A)
# But they may not expand to 1 or N indices; ensure the above doesn't shadow the general indexing fallbacks
@propagate_inbounds getindex{T}(A::Array{T}, i1::Int, I::Int...) =
_getindex(LinearFast(), A, i1, I...)
@propagate_inbounds setindex!{T}(A::Array{T}, v, i1::Int, I::Int...) =
_setindex!(LinearFast(), A, v, i1, I...)

# Support indexing with an array of CartesianIndex{N}s
# Here we try to consume N of the indices (if there are that many available)
Expand Down Expand Up @@ -371,11 +376,10 @@ getindex(t::Tuple, I...) = getindex(t, IteratorsMD.flatten(I)...)
end
end
# But we can speed up LinearSlow arrays by reshaping them to the appropriate dimensionality:
_maybe_reshape(::LinearFast, A::AbstractArray, I...) = A
_maybe_reshape(::LinearSlow, A::AbstractVector, I...) = A
@inline _maybe_reshape(::LinearSlow, A::AbstractArray, I...) = __maybe_reshape(A, index_ndims(I...))
@inline __maybe_reshape{T,N}(A::AbstractArray{T,N}, ::NTuple{N}) = A
@inline __maybe_reshape{N}(A::AbstractArray, ::NTuple{N}) = reshape(A, Val{N})
@inline _maybe_reshape(l::LinearIndexing, A::AbstractArray, I...) = __maybe_reshape(l, A, index_ndims(I...))
@inline __maybe_reshape{T,N}(::LinearSlow, A::AbstractArray{T,N}, ::NTuple{N}) = A
@inline __maybe_reshape{T,N}(::LinearSlow, A::AbstractArray{T,N}, ::NTuple{1}) = reshape(A, Val{1})
@inline __maybe_reshape{T,N}(::LinearFast, A::AbstractArray{T,N}, ::Any) = A

@generated function _unsafe_getindex(::LinearIndexing, A::AbstractArray, I::Union{Real, AbstractArray}...)
N = length(I)
Expand Down
1 change: 0 additions & 1 deletion base/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ parentindexes(a::AbstractArray) = ntuple(i->OneTo(size(a,i)), ndims(a))
# can make the number of effective indices not equal to length(I).
_maybe_reshape_parent(A::AbstractArray, ::NTuple{1, Bool}) = reshape(A, Val{1})
_maybe_reshape_parent{_,N}(A::AbstractArray{_,N}, ::NTuple{N, Bool}) = A
_maybe_reshape_parent{N}(A::AbstractArray, ::NTuple{N, Bool}) = reshape(A, Val{N}) # TODO: DEPRECATE FOR #14770
"""
view(A, inds...)

Expand Down
Loading