Skip to content

Commit 3f4caf5

Browse files
hotfix VectorOfArray Cartesian indexing
1 parent 6866437 commit 3f4caf5

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RecursiveArrayTools"
22
uuid = "731186ca-8d62-57ce-b412-fbd966d074cd"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "2.3.4"
4+
version = "2.3.5"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/vector_of_array.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Base.@propagate_inbounds Base.getindex(VA::AbstractDiffEqArray{T, N}, I::Abstrac
4141
Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, i::Int,::Colon) where {T, N} = [VA.u[j][i] for j in 1:length(VA)]
4242
Base.@propagate_inbounds function Base.getindex(VA::AbstractVectorOfArray{T,N}, ii::CartesianIndex) where {T, N}
4343
ti = Tuple(ii)
44-
i = first(ti)
45-
jj = CartesianIndex(Base.tail(ti))
44+
i = last(ti)
45+
jj = CartesianIndex(Base.front(ti))
4646
return VA.u[i][jj]
4747
end
4848
Base.@propagate_inbounds Base.setindex!(VA::AbstractVectorOfArray{T, N}, v, I::Int) where {T, N} = VA.u[I] = v
@@ -56,8 +56,8 @@ Base.@propagate_inbounds function Base.setindex!(VA::AbstractVectorOfArray{T, N}
5656
end
5757
Base.@propagate_inbounds function Base.setindex!(VA::AbstractVectorOfArray{T,N}, x, ii::CartesianIndex) where {T, N}
5858
ti = Tuple(ii)
59-
i = first(ti)
60-
jj = CartesianIndex(Base.tail(ti))
59+
i = last(ti)
60+
jj = CartesianIndex(Base.front(ti))
6161
return VA.u[i][jj] = x
6262
end
6363

test/basic_indexing.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@ testva[1:2, 1:2]
7575

7676
# Test broadcast
7777
a = testva .+ rand(3,3)
78-
@test_broken a.= testva
78+
a.= testva
79+
@test all(a .== testva)
7980

8081
recs = [rand(2,2) for i in 1:5]
8182
testva = VectorOfArray(recs)
8283
@test Array(testva) isa Array{Float64,3}
8384

8485
v = VectorOfArray([zeros(20), zeros(10,10), zeros(3,3,3)])
85-
v[CartesianIndex((3, 2, 3, 2))] = 1
86-
@test v[CartesianIndex((3, 2, 3, 2))] == 1
86+
v[CartesianIndex((2, 3, 2, 3))] = 1
87+
@test v[CartesianIndex((2, 3, 2, 3))] == 1
8788
@test v.u[3][2, 3, 2] == 1

test/upstream.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ sol = solve(prob,Tsit5())
1212
sol = solve(prob,AutoTsit5(Rosenbrock23(autodiff=false)))
1313
sol = solve(prob,AutoTsit5(Rosenbrock23()))
1414

15+
@test all(Array(sol) .== sol)
16+
1517
function f!(F, vars)
1618
x = vars.x[1]
1719
F.x[1][1] = (x[1]+3)*(x[2]^3-7)+18

0 commit comments

Comments
 (0)