Skip to content

Commit

Permalink
Consider strided views of reinterpret strided (JuliaLang#26664)
Browse files Browse the repository at this point in the history
Restores a bit more of the 0.6 reinterpret behavior. Fixes JuliaLang#26662.
  • Loading branch information
mbauman committed Apr 4, 2018
1 parent d7e6c16 commit efd6806
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ include("strings/string.jl")

# Definition of StridedArray
StridedFastContiguousSubArray{T,N,A<:DenseArray} = FastContiguousSubArray{T,N,A}
StridedReshapedArray{T,N,A<:Union{DenseArray,StridedFastContiguousSubArray}} = ReshapedArray{T,N,A}
StridedReinterpretArray{T,N,A<:Union{DenseArray,StridedFastContiguousSubArray}} = ReinterpretArray{T,N,S,A} where S
StridedSubArray{T,N,A<:Union{DenseArray,StridedReshapedArray},
StridedReshapedArray{T,N,A<:Union{DenseArray,StridedFastContiguousSubArray,StridedReinterpretArray}} = ReshapedArray{T,N,A}
StridedSubArray{T,N,A<:Union{DenseArray,StridedReshapedArray,StridedReinterpretArray},
I<:Tuple{Vararg{Union{RangeIndex, AbstractCartesianIndex}}}} = SubArray{T,N,A,I}
StridedArray{T,N} = Union{DenseArray{T,N}, StridedSubArray{T,N}, StridedReshapedArray{T,N}, StridedReinterpretArray{T,N}}
StridedVector{T} = Union{DenseArray{T,1}, StridedSubArray{T,1}, StridedReshapedArray{T,1}, StridedReinterpretArray{T,1}}
Expand Down
8 changes: 8 additions & 0 deletions test/reinterpretarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ let A = reshape(1:20, 5, 4)
@test !(R2 isa StridedArray)
@test R * ones(4, 5) == R2 * ones(4,5) == copy(R) * ones(4,5) == copy(R2) * ones(4,5)
end

# but ensure that strided views of strided reinterpret arrays are still strided
let A = collect(reshape(1:20, 5, 4))
R = reinterpret(Int32, A)
@test R isa StridedArray
@test view(R, :, :) isa StridedArray
@test reshape(R, :) isa StridedArray
end

0 comments on commit efd6806

Please sign in to comment.