@@ -145,6 +145,31 @@ diffeq = DiffEqArray(recs, t)
145145@test diffeq[:, 1 ] == recs[1 ]
146146@test diffeq[1 : 2 , 1 : 2 ] == [1 3 ; 2 5 ]
147147
148+ # Test views of heterogeneous arrays (issue #453)
149+ f = VectorOfArray ([[1.0 ], [2.0 , 3.0 ]])
150+ @test length (view (f, :, 1 )) == 1
151+ @test length (view (f, :, 2 )) == 2
152+ @test view (f, :, 1 ) == [1.0 ]
153+ @test view (f, :, 2 ) == [2.0 , 3.0 ]
154+ @test collect (view (f, :, 1 )) == f[:, 1 ]
155+ @test collect (view (f, :, 2 )) == f[:, 2 ]
156+
157+ f2 = VectorOfArray ([[1.0 , 2.0 ], [3.0 ]])
158+ @test length (view (f2, :, 1 )) == 2
159+ @test length (view (f2, :, 2 )) == 1
160+ @test view (f2, :, 1 ) == [1.0 , 2.0 ]
161+ @test view (f2, :, 2 ) == [3.0 ]
162+ @test collect (view (f2, :, 1 )) == f2[:, 1 ]
163+ @test collect (view (f2, :, 2 )) == f2[:, 2 ]
164+
165+ # Test that views can be modified
166+ f3 = VectorOfArray ([[1.0 , 2.0 ], [3.0 , 4.0 , 5.0 ]])
167+ v = view (f3, :, 2 )
168+ @test length (v) == 3
169+ v[1 ] = 10.0
170+ @test f3[1 , 2 ] == 10.0
171+ @test f3. u[2 ][1 ] == 10.0
172+
148173t = 1 : 5
149174recs = [rand (2 , 2 ) for i in 1 : 5 ]
150175testva = VectorOfArray (recs)
0 commit comments