You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix unaliascopy(::SubArray) with indices of Array{<:CartesianIndex} (#47779)
This PR fixes the bug caused by the trimming trick.
`Base.index_lengths` is not a proper tool to calculate the trimmed shape
as `indices` might consume more than 1 dim.
And we can avoid the unneeded "`repeat`" when we meet
`Array{CartesianIndex{0}}`
Test added.
Close#47644.
# When the parent is an Array we can trim the size down a bit. In the future this
112
112
# could possibly be extended to any mutable array.
113
-
functionunaliascopy(V::SubArray{T,N,A,I,LD}) where {T,N,A<:Array,I<:Tuple{Vararg{Union{Real,AbstractRange,Array}}},LD}
114
-
dest =Array{T}(undef, index_lengths(V.indices...))
115
-
copyto!(dest, V)
113
+
functionunaliascopy(V::SubArray{T,N,A,I,LD}) where {T,N,A<:Array,I<:Tuple{Vararg{Union{ScalarIndex,AbstractRange{<:ScalarIndex},Array{<:Union{ScalarIndex,AbstractCartesianIndex}}}}},LD}
114
+
dest =Array{T}(undef, _trimmedshape(V.indices...))
115
+
trimmedpind =_trimmedpind(V.indices...)
116
+
vdest = trimmedpind isa Tuple{Vararg{Union{Slice,Colon}}} ? dest :view(dest, trimmedpind...)
0 commit comments