@@ -192,6 +192,38 @@ ragged2 = VectorOfArray([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0], [7.0, 8.0, 9.0]])
192192@test ragged2[1 : (end - 1 ), 2 ] == [5.0 ]
193193@test ragged2[1 : (end - 1 ), 3 ] == [7.0 , 8.0 ]
194194
195+ # Broadcasting of heterogeneous arrays (issue #454)
196+ u = VectorOfArray ([[1.0 ], [2.0 , 3.0 ]])
197+ @test length (view (u, :, 1 )) == 1
198+ @test length (view (u, :, 2 )) == 2
199+ # broadcast assignment into selected column (last index Int)
200+ u[:, 2 ] .= [10.0 , 11.0 ]
201+ @test u. u[2 ] == [10.0 , 11.0 ]
202+
203+ # 2D inner arrays (matrices) with ragged second dimension
204+ u = VectorOfArray ([zeros (1 , n) for n in (2 , 3 )])
205+ @test length (view (u, 1 , :, 1 )) == 2
206+ @test length (view (u, 1 , :, 2 )) == 3
207+ u[1 , :, 2 ] .= [1.0 , 2.0 , 3.0 ]
208+ @test u. u[2 ] == [1.0 2.0 3.0 ]
209+ # partial column selection by indices
210+ u[1 , [1 , 3 ], 2 ] .= [7.0 , 9.0 ]
211+ @test u. u[2 ] == [7.0 2.0 9.0 ]
212+
213+ # 3D inner arrays (tensors) with ragged third dimension
214+ u = VectorOfArray ([zeros (2 , 1 , n) for n in (2 , 3 )])
215+ @test size (view (u, :, :, :, 1 )) == (2 , 1 , 2 )
216+ @test size (view (u, :, :, :, 2 )) == (2 , 1 , 3 )
217+ # assign into a slice of the second inner array using last index Int
218+ u[2 , 1 , :, 2 ] .= [7.0 , 8.0 , 9.0 ]
219+ @test vec (u. u[2 ][2 , 1 , :]) == [7.0 , 8.0 , 9.0 ]
220+ # check mixed slicing with range on front dims
221+ u[1 : 2 , 1 , [1 , 3 ], 2 ] .= [1.0 3.0 ; 2.0 4.0 ]
222+ @test u. u[2 ][1 , 1 , 1 ] == 1.0
223+ @test u. u[2 ][2 , 1 , 1 ] == 2.0
224+ @test u. u[2 ][1 , 1 , 3 ] == 3.0
225+ @test u. u[2 ][2 , 1 , 3 ] == 4.0
226+
195227# Test that views can be modified
196228f3 = VectorOfArray ([[1.0 , 2.0 ], [3.0 , 4.0 , 5.0 ]])
197229v = view (f3, :, 2 )
0 commit comments