|
70 | 70 | @test s[100] == s[10, 10] == (a=1, b=1)
|
71 | 71 | s[10, 10] = (a=0, b=0)
|
72 | 72 | @test s[100] == s[10, 10] == (a=0, b=0)
|
| 73 | + |
| 74 | + # inference for "many" types, both for linear ad Cartesian indexing |
| 75 | + @inferred StructArrays.index_type(NTuple{2, Vector{Float64}}) |
| 76 | + @inferred StructArrays.index_type(NTuple{3, Matrix{Float64}}) |
| 77 | + @inferred StructArrays.index_type(NTuple{4, Array{Float64, 3}}) |
| 78 | + |
| 79 | + @inferred StructArrays.index_type(NTuple{2, SubArray{Float64, 1, Array{Float64, 2}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}) |
| 80 | + @inferred StructArrays.index_type(NTuple{3, SubArray{Float64, 1, Array{Float64, 2}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}) |
| 81 | + @inferred StructArrays.index_type(NTuple{4, SubArray{Float64, 1, Array{Float64, 2}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}) |
73 | 82 | end
|
74 | 83 |
|
75 | 84 | @testset "replace_storage" begin
|
@@ -818,9 +827,8 @@ Base.similar(bc::Broadcast.Broadcasted{Broadcast.ArrayStyle{MyArray}}, ::Type{El
|
818 | 827 | end
|
819 | 828 |
|
820 | 829 | @testset "staticarrays" begin
|
821 |
| - |
822 | 830 | # test that staticschema returns the right things
|
823 |
| - for StaticVectorType = [SVector, MVector, SizedVector] |
| 831 | + for StaticVectorType = [SVector, MVector, SizedVector] |
824 | 832 | @test StructArrays.staticschema(StaticVectorType{2,Float64}) == Tuple{Float64,Float64}
|
825 | 833 | end
|
826 | 834 |
|
|
838 | 846 | @test StructArrays.components(x) == ([1., 2.], [1., 2.])
|
839 | 847 | @test x .+ y == StructArray([StaticArrayType{Tuple{1,2}}(3*ones(1,2) .+ 2*i) for i = 0:1])
|
840 | 848 | end
|
| 849 | + |
| 850 | + # test type stability of creating views with "many" homogeneous components |
| 851 | + for n in 1:10 |
| 852 | + u = StructArray(randn(SVector{n, Float64}) for _ in 1:10, _ in 1:5) |
| 853 | + @inferred view(u, :, 1) |
| 854 | + @inferred view(u, 1, :) |
| 855 | + end |
841 | 856 | end
|
0 commit comments