|
63 | 63 | @test isa(similar(sv, (3,3,3)), MArray{(3,3,3),Int,3,27})
|
64 | 64 | @test isa(similar(sv, Float64, (3,3,3)), MArray{(3,3,3),Float64,3,27})
|
65 | 65 | end
|
66 |
| -#= |
67 |
| - @testset "size and length" begin |
68 |
| - vec = [1,2,3,4] |
69 |
| - sv = SVector{(4,)}(vec) |
70 |
| - mv = MVector{(4,)}(vec) |
71 |
| -
|
72 |
| - mat = eye(3) |
73 |
| - sm = MMatrix{(3,3)}(mat) |
74 |
| - mm = MMatrix{(3,3)}(mat) |
75 |
| -
|
76 |
| - @test size(sv) == size(vec) |
77 |
| - @test size(mv) == size(vec) |
78 |
| - @test size(sm) == size(mat) |
79 |
| - @test size(mm) == size(mat) |
80 |
| -
|
81 |
| - @test size(sv,1) == size(vec,1) |
82 |
| - @test size(mv,1) == size(vec,1) |
83 |
| - @test size(sm,1) == size(mat,1) |
84 |
| - @test size(mm,1) == size(mat,1) |
85 |
| - @test size(sv,2) == size(vec,2) # Test for |
86 |
| - @test size(mv,2) == size(vec,2) # trailing 1's |
87 |
| - @test size(sm,2) == size(mat,2) |
88 |
| - @test size(mm,2) == size(mat,2) |
89 |
| -
|
90 |
| - @test length(sv) == length(vec) |
91 |
| - @test length(mv) == length(vec) |
92 |
| - @test length(sm) == length(mat) |
93 |
| - @test length(mm) == length(mat) |
94 |
| -
|
95 |
| - @test size(typeof(sv)) == size(vec) |
96 |
| - @test size(typeof(mv)) == size(vec) |
97 |
| - @test size(typeof(sm)) == size(mat) |
98 |
| - @test size(typeof(mm)) == size(mat) |
99 |
| -
|
100 |
| - @test size(typeof(sv),1) == size(vec,1) |
101 |
| - @test size(typeof(mv),1) == size(vec,1) |
102 |
| - @test size(typeof(sm),1) == size(mat,1) |
103 |
| - @test size(typeof(mm),1) == size(mat,1) |
104 |
| - @test size(typeof(sv),2) == size(vec,2) # Test for |
105 |
| - @test size(typeof(mv),2) == size(vec,2) # trailing 1's |
106 |
| - @test size(typeof(sm),2) == size(mat,2) |
107 |
| - @test size(typeof(mm),2) == size(mat,2) |
108 |
| -
|
109 |
| - @test length(typeof(sv)) == length(vec) |
110 |
| - @test length(typeof(mv)) == length(vec) |
111 |
| - @test length(typeof(sm)) == length(mat) |
112 |
| - @test length(typeof(mm)) == length(mat) |
113 |
| - end |
114 |
| -
|
115 |
| - @testset "Miscellanious introspection" begin |
116 |
| - vec = [1,2,3,4] |
117 |
| - sv = SVector{(4,)}(vec) |
118 |
| - mv = MVector{(4,)}(vec) |
119 |
| -
|
120 |
| - @test Base.isassigned(sv, 4) == Base.isassigned(vec, 4) |
121 |
| - @test Base.isassigned(sv, 5) == Base.isassigned(vec, 5) |
122 |
| - @test Base.isassigned(sv, 2, 1) == Base.isassigned(vec, 2, 1) # test for trailing ones |
123 |
| - @test Base.isassigned(mv, 4) == Base.isassigned(vec, 4) |
124 |
| - @test Base.isassigned(mv, 5) == Base.isassigned(vec, 5) |
125 |
| - @test Base.isassigned(mv, 2, 1) == Base.isassigned(vec, 2, 1) |
126 | 66 |
|
127 |
| - @test Base.linearindexing(sv) == Base.LinearFast() |
128 |
| - @test Base.linearindexing(mv) == Base.LinearFast() |
129 |
| - @test Base.linearindexing(typeof(sv)) == Base.LinearFast() |
130 |
| - @test Base.linearindexing(typeof(mv)) == Base.LinearFast() |
| 67 | + @testset "reshape" begin |
| 68 | + @test reshape(SVector(1,2,3,4), Size(2,2)) === SMatrix{2,2}(1,2,3,4) |
| 69 | + @test reshape([1,2,3,4], Size(2,2))::SizedArray{(2,2),Int,2,1} == [1 3; 2 4] |
131 | 70 | end
|
132 |
| -
|
133 |
| - @testset "similar and similar_type" begin |
134 |
| - vec = [1,2,3,4] |
135 |
| - sv = SVector{(4,)}(vec) |
136 |
| - mv = MVector{(4,)}(vec) |
137 |
| -
|
138 |
| - @test_throws Exception similar(sv) |
139 |
| - @test typeof(similar(mv)) == typeof(mv) |
140 |
| - @test_inferred similar(mv) |
141 |
| - @test_throws Exception similar(sv, Float64) |
142 |
| - @test typeof(similar(mv, Float64)) <: MVector{(4,),Float64} |
143 |
| - @test_inferred similar(mv, Float64) |
144 |
| - @test_throws Exception similar(sv, (2,2)) |
145 |
| - @test_throws Exception similar(mv, (2,2)) |
146 |
| - @test_throws Exception similar(sv, Float64, (2,2)) |
147 |
| - @test_throws Exception similar(mv, Float64, (2,2)) |
148 |
| - @test_throws Exception similar(sv, Val{(2,2)}) |
149 |
| - @test typeof(similar(mv, Val{(2,2)})) <: MArray{(2,2),Int} |
150 |
| - @test_inferred similar(mv, Val{(2,2)}) |
151 |
| - @test_throws Exception similar(sv, Float64, Val{(2,2)}) |
152 |
| - @test typeof(similar(mv, Float64, Val{(2,2)})) <: MArray{(2,2),Float64} |
153 |
| - @test_inferred similar(mv, Float64, Val{(2,2)}) |
154 |
| -
|
155 |
| - @test similar_type(sv) == typeof(sv) |
156 |
| - @test_inferred similar_type(sv) |
157 |
| - @test similar_type(mv) == typeof(mv) |
158 |
| - @test_inferred similar_type(mv) |
159 |
| - @test similar_type(sv, Float64) == SArray{(4,),Float64,1,NTuple{4,Float64}} |
160 |
| - @test_inferred similar_type(sv, Float64) |
161 |
| - @test similar_type(mv, Float64) == MArray{(4,),Float64,1,NTuple{4,Float64}} |
162 |
| - @test_inferred similar_type(mv, Float64) |
163 |
| - @test_throws Exception similar_type(sv, (2,2)) |
164 |
| - @test_throws Exception similar_type(mv, (2,2)) |
165 |
| - @test_throws Exception similar_type(sv, Float64, (2,2)) |
166 |
| - @test_throws Exception similar_type(mv, Float64, (2,2)) |
167 |
| - @test similar_type(sv, Val{(2,2)}) == SArray{(2,2),Int,2,NTuple{4,Int}} |
168 |
| - @test_inferred similar_type(sv, Val{(2,2)}) |
169 |
| - @test similar_type(mv, Val{(2,2)}) == MArray{(2,2),Int,2,NTuple{4,Int}} |
170 |
| - @test_inferred similar_type(mv, Val{(2,2)}) |
171 |
| - @test similar_type(sv, Float64, Val{(2,2)}) == SArray{(2,2),Float64,2,NTuple{4,Float64}} |
172 |
| - @test_inferred similar_type(sv, Float64, Val{(2,2)}) |
173 |
| - @test similar_type(mv, Float64, Val{(2,2)}) == MArray{(2,2),Float64,2,NTuple{4,Float64}} |
174 |
| - @test_inferred similar_type(mv, Float64, Val{(2,2)}) |
175 |
| - end |
176 |
| -
|
177 |
| - @testset "reshape and permutedims" begin |
178 |
| - vec = [4,5,6,7] |
179 |
| - sv = SVector{(4,)}(vec) |
180 |
| - mv = MVector{(4,)}(vec) |
181 |
| -
|
182 |
| - mat = reshape(vec,(2,2)) |
183 |
| - sm = SMatrix{(2,2)}(mat) |
184 |
| - mm = MMatrix{(2,2)}(mat) |
185 |
| -
|
186 |
| - @test reshape(sv, Val{(2,2)}) === sm |
187 |
| - @test_inferred reshape(sv, Val{(2,2)}) |
188 |
| - @test reshape(mv, Val{(2,2)}) == mm |
189 |
| - @test_inferred reshape(mv, Val{(2,2)}) |
190 |
| - @test isa(reshape(mv, Val{(2,2)}), MMatrix) |
191 |
| - @test_throws Exception reshape(sv, (2,2)) == sm |
192 |
| - @test_throws Exception reshape(sv, (2,2)) == sm |
193 |
| -
|
194 |
| - end |
195 |
| -
|
196 |
| - =# |
197 | 71 | end
|
0 commit comments