We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1665eec commit 5931fb5Copy full SHA for 5931fb5
src/abstractarray.jl
@@ -130,7 +130,7 @@ similar(::A,::Type{T},s::Size{S}) where {A<:AbstractArray,T,S} = similar(A,T,s)
130
131
# defaults to built-in mutable types for bits types
132
similar(::Type{A}, ::Type{T}, s::Size{S}) where {A<:AbstractArray,T,S} =
133
- isbitstype(eltype(A)) ?
+ isbitstype(eltype(T)) ?
134
mutable_similar_type(T, s, length_val(s))(undef) :
135
sizedarray_similar_type(T, s, length_val(s))(undef)
136
test/abstractarray.jl
@@ -59,6 +59,7 @@ using StaticArrays, Test, LinearAlgebra
59
sv = @SVector [1,2,3]
60
sm = @SMatrix [1 2; 3 4]
61
sa = SArray{Tuple{1,1,1},Int,3,1}((1,))
62
+ sn = @SVector [1, missing]
63
64
@test isa(@inferred(similar(sv)), MVector{3,Int})
65
@test isa(@inferred(similar(sv, Float64)), MVector{3,Float64})
@@ -69,6 +70,8 @@ using StaticArrays, Test, LinearAlgebra
69
70
@test isa(@inferred(similar(sm, Float64)), MMatrix{2,2,Float64,4})
71
@test isa(@inferred(similar(sv, Size(3,3))), MMatrix{3,3,Int,9})
72
@test isa(@inferred(similar(sv, Float64, Size(3,3))), MMatrix{3,3,Float64,9})
73
+ @test isa(@inferred(similar(sn)), SizedVector{2, Union{Missing, Int64}, Vector{Union{Missing, Int64}}})
74
+ @test isa(@inferred(similar(sn, Float64, Size(3, 3))), MMatrix{3, 3, Float64, 9})
75
76
@test isa(@inferred(similar(sa)), MArray{Tuple{1,1,1},Int,3,1})
77
@test isa(@inferred(similar(SArray{Tuple{1,1,1},Int,3,1})), MArray{Tuple{1,1,1},Int,3,1})
0 commit comments