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
This restructures the similar method table along the lines that I suggested in #568 (comment). I also used a bit of internals magic to match how the Base `OneTo` operates -- this is a little fragile but I think it is a good way to replicate how `OneTo` works.
similar(::A,::Type{T}, shape::Tuple{SOneToLike, Vararg{SOneToLike}}) where {A<:AbstractArray,T} =similar(A, T, Size(last.(deslice.(shape))))
133
-
similar(::Type{A},::Type{T}, shape::Tuple{SOneToLike, Vararg{SOneToLike}}) where {A<:AbstractArray,T} =similar(A, T, Size(last.(deslice.(shape))))
128
+
similar(A::AbstractArray, ::Type{T}, shape::Tuple{HeterogeneousShape, Vararg{HeterogeneousShape}}) where {T} =similar(A, T, homogenize_shape(shape))
129
+
similar(::Type{A}, shape::Tuple{HeterogeneousShape, Vararg{HeterogeneousShape}}) where {A<:AbstractArray} =similar(A, homogenize_shape(shape))
130
+
# Use an Array for StaticArrays if we don't have a statically-known size
131
+
similar(::Type{A}, shape::Tuple{Int, Vararg{Int}}) where {A<:StaticArray} =Array{eltype(A)}(undef, shape)
134
132
135
-
# Handle mixtures of SOneTo and other ranges (probably should make Base more robust here)
136
-
similar(::Type{A}, shape::Tuple{AbstractUnitRange, Vararg{AbstractUnitRange}}) where {A<:AbstractArray} =similar(A, length.(shape))# Jumps back to 2-argument form in Base
137
-
similar(::Type{A},::Type{T}, shape::Tuple{AbstractUnitRange, Vararg{AbstractUnitRange}}) where {A<:AbstractArray,T} =similar(A, length.(shape))
0 commit comments