@@ -15,8 +15,6 @@ fill!(mulX, 0)
1515mulX .= sqrt .(abs .(testva .* X))
1616@test mulX == ref
1717
18- t = [1 ,2 ,3 ]
19- diffeq = DiffEqArray (recs,t)
2018@test Array (testva) == [1 4 7
2119 2 5 8
2220 3 6 9 ]
@@ -25,7 +23,15 @@ diffeq = DiffEqArray(recs,t)
2523@test testva[1 : 2 , 1 : 2 ] == [1 4 ; 2 5 ]
2624@test testa[1 : 2 , 1 : 2 ] == [1 4 ; 2 5 ]
2725
26+ t = [1 ,2 ,3 ]
27+ diffeq = DiffEqArray (recs,t)
28+ @test Array (diffeq) == [1 4 7
29+ 2 5 8
30+ 3 6 9 ]
31+ @test diffeq[1 : 2 , 1 : 2 ] == [1 4 ; 2 5 ]
32+
2833# # ndims == 2
34+ t = 1 : 10
2935recs = [rand (8 ) for i in 1 : 10 ]
3036testa = cat (recs... ,dims= 2 )
3137testva = VectorOfArray (recs)
@@ -36,63 +42,100 @@ testva = VectorOfArray(recs)
3642@test testva[end ] == testa[:, end ]
3743@test testva[2 : end ] == VectorOfArray ([recs[i] for i = 2 : length (recs)])
3844
45+ diffeq = DiffEqArray (recs,t)
46+ @test diffeq[1 ] == testa[:, 1 ]
47+ @test diffeq[:] == recs
48+ @test diffeq[end ] == testa[:, end ]
49+ @test diffeq[2 : end ] == DiffEqArray ([recs[i] for i = 2 : length (recs)], t)
50+
3951# ## (Int, Int)
4052@test testa[5 , 4 ] == testva[5 , 4 ]
53+ @test testa[5 , 4 ] == diffeq[5 , 4 ]
4154
4255# ## (Int, Range) or (Range, Int)
4356@test testa[1 , 2 : 3 ] == testva[1 , 2 : 3 ]
4457@test testa[5 : end , 1 ] == testva[5 : end , 1 ]
4558@test testa[:, 1 ] == testva[:, 1 ]
4659@test testa[3 , :] == testva[3 , :]
4760
61+ @test testa[1 , 2 : 3 ] == diffeq[1 , 2 : 3 ]
62+ @test testa[5 : end , 1 ] == diffeq[5 : end , 1 ]
63+ @test testa[:, 1 ] == diffeq[:, 1 ]
64+ @test testa[3 , :] == diffeq[3 , :]
65+
4866# ## (Range, Range)
4967@test testa[5 : end , 1 : 2 ] == testva[5 : end , 1 : 2 ]
68+ @test testa[5 : end , 1 : 2 ] == diffeq[5 : end , 1 : 2 ]
5069
5170# # ndims == 3
71+ t = 1 : 15
5272recs = recs = [rand (10 , 8 ) for i in 1 : 15 ]
5373testa = cat (recs... ,dims= 3 )
5474testva = VectorOfArray (recs)
75+ diffeq = DiffEqArray (recs,t)
5576
5677# ## (Int, Int, Int)
5778@test testa[1 , 7 , 14 ] == testva[1 , 7 , 14 ]
79+ @test testa[1 , 7 , 14 ] == diffeq[1 , 7 , 14 ]
5880
5981# ## (Int, Int, Range)
6082@test testa[2 , 3 , 1 : 2 ] == testva[2 , 3 , 1 : 2 ]
83+ @test testa[2 , 3 , 1 : 2 ] == diffeq[2 , 3 , 1 : 2 ]
6184
6285# ## (Int, Range, Int)
6386@test testa[2 , 3 : 4 , 1 ] == testva[2 , 3 : 4 , 1 ]
87+ @test testa[2 , 3 : 4 , 1 ] == diffeq[2 , 3 : 4 , 1 ]
6488
6589# ## (Int, Range, Range)
6690@test testa[2 , 3 : 4 , 1 : 2 ] == testva[2 , 3 : 4 , 1 : 2 ]
91+ @test testa[2 , 3 : 4 , 1 : 2 ] == diffeq[2 , 3 : 4 , 1 : 2 ]
6792
6893# ## (Range, Int, Range)
6994@test testa[2 : 3 , 1 , 1 : 2 ] == testva[2 : 3 , 1 , 1 : 2 ]
95+ @test testa[2 : 3 , 1 , 1 : 2 ] == diffeq[2 : 3 , 1 , 1 : 2 ]
7096
7197# ## (Range, Range, Int)
7298@test testa[1 : 2 , 2 : 3 , 1 ] == testva[1 : 2 , 2 : 3 , 1 ]
99+ @test testa[1 : 2 , 2 : 3 , 1 ] == diffeq[1 : 2 , 2 : 3 , 1 ]
73100
74101# ## (Range, Range, Range)
75102@test testa[2 : 3 , 2 : 3 , 1 : 2 ] == testva[2 : 3 , 2 : 3 , 1 : 2 ]
103+ @test testa[2 : 3 , 2 : 3 , 1 : 2 ] == diffeq[2 : 3 , 2 : 3 , 1 : 2 ]
76104
77105# ## Make sure that 1:1 like ranges are not collapsed
78106@test testa[1 : 1 , 2 : 3 , 1 : 2 ] == testva[1 : 1 , 2 : 3 , 1 : 2 ]
107+ @test testa[1 : 1 , 2 : 3 , 1 : 2 ] == diffeq[1 : 1 , 2 : 3 , 1 : 2 ]
79108
80109# ## Test ragged arrays work, or give errors as needed
81110# TODO : I am not really sure what the behavior of this is, what does Mathematica do?
111+ t = 1 : 3
82112recs = [[1 , 2 , 3 ], [3 , 5 , 6 , 7 ], [8 , 9 , 10 , 11 ]]
83113testva = VectorOfArray (recs) # TODO : clearly this printed form is nonsense
114+ diffeq = DiffEqArray (recs,t)
115+
84116@test testva[:, 1 ] == recs[1 ]
85- testva[1 : 2 , 1 : 2 ]
117+ @test testva[1 : 2 , 1 : 2 ] == [1 3 ; 2 5 ]
118+ @test diffeq[:, 1 ] == recs[1 ]
119+ @test diffeq[1 : 2 , 1 : 2 ] == [1 3 ; 2 5 ]
86120
121+ t = 1 : 5
87122recs = [rand (2 ,2 ) for i in 1 : 5 ]
88123testva = VectorOfArray (recs)
124+ diffeq = DiffEqArray (recs,t)
125+
89126@test Array (testva) isa Array{Float64,3 }
127+ @test Array (diffeq) isa Array{Float64,3 }
90128
91129v = VectorOfArray ([zeros (20 ), zeros (10 ,10 ), zeros (3 ,3 ,3 )])
92130v[CartesianIndex ((2 , 3 , 2 , 3 ))] = 1
93131@test v[CartesianIndex ((2 , 3 , 2 , 3 ))] == 1
94132@test v. u[3 ][2 , 3 , 2 ] == 1
95133
134+ v = DiffEqArray ([zeros (20 ), zeros (10 ,10 ), zeros (3 ,3 ,3 )], 1 : 3 )
135+ v[CartesianIndex ((2 , 3 , 2 , 3 ))] = 1
136+ @test v[CartesianIndex ((2 , 3 , 2 , 3 ))] == 1
137+ @test v. u[3 ][2 , 3 , 2 ] == 1
138+
96139v = VectorOfArray ([rand (20 ), rand (10 ,10 ), rand (3 ,3 ,3 )])
97140w = v .* v
98141@test w isa VectorOfArray
@@ -103,12 +146,25 @@ w = v .* v
103146x = copy (v)
104147x .= v .* v
105148@test x. u == w. u
106-
107- # broadcast with number
108149w = v .+ 1
109150@test w isa VectorOfArray
110151@test w. u == map (x -> x .+ 1 , v. u)
111152
153+
154+ v = DiffEqArray ([rand (20 ), rand (10 ,10 ), rand (3 ,3 ,3 )], 1 : 3 )
155+ w = v .* v
156+ @test_broken w isa DiffEqArray # FIXME
157+ @test w[1 ] isa Vector
158+ @test w[1 ] == v[1 ] .* v[1 ]
159+ @test w[2 ] == v[2 ] .* v[2 ]
160+ @test w[3 ] == v[3 ] .* v[3 ]
161+ x = copy (v)
162+ x .= v .* v
163+ @test x. u == w. u
164+ w = v .+ 1
165+ @test_broken w isa DiffEqArray # FIXME
166+ @test w. u == map (x -> x .+ 1 , v. u)
167+
112168# edges cases
113169x = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]
114170testva = DiffEqArray (x, x)
0 commit comments