Skip to content

Commit 549b754

Browse files
committed
Add tests
1 parent 8d6155f commit 549b754

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

test/basic_indexing.jl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ using RecursiveArrayTools, Test
44
recs = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
55
testa = cat(recs..., dims=2)
66
testva = VectorOfArray(recs)
7+
8+
# broadcast with array
9+
X = rand(3, 3)
10+
mulX = testva .* X
11+
ref = mapreduce((x,y)->x.*y, hcat, testva, eachcol(X))
12+
@test mulX == ref
13+
fill!(mulX, 0)
14+
mulX .= testva .* X
15+
@test mulX == ref
16+
717
t = [1,2,3]
818
diffeq = DiffEqArray(recs,t)
919
@test Array(testva) == [1 4 7
@@ -73,11 +83,6 @@ testva = VectorOfArray(recs) #TODO: clearly this printed form is nonsense
7383
@test testva[:, 1] == recs[1]
7484
testva[1:2, 1:2]
7585

76-
# Test broadcast
77-
a = testva .+ rand(3,3)
78-
a.= testva
79-
@test all(a .== testva)
80-
8186
recs = [rand(2,2) for i in 1:5]
8287
testva = VectorOfArray(recs)
8388
@test Array(testva) isa Array{Float64,3}
@@ -97,3 +102,8 @@ w = v .* v
97102
x = copy(v)
98103
x .= v .* v
99104
@test x.u == w.u
105+
106+
# broadcast with number
107+
w = v .+ 1
108+
@test w isa VectorOfArray
109+
@test w.u == map(x -> x .+ 1, v.u)

0 commit comments

Comments
 (0)