From 3f4caf5dcd4a61709baac184be048326510963be Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Wed, 27 May 2020 06:59:58 -0400 Subject: [PATCH] hotfix VectorOfArray Cartesian indexing --- Project.toml | 2 +- src/vector_of_array.jl | 8 ++++---- test/basic_indexing.jl | 7 ++++--- test/upstream.jl | 2 ++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index c0ede0d6..73e6b97c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RecursiveArrayTools" uuid = "731186ca-8d62-57ce-b412-fbd966d074cd" authors = ["Chris Rackauckas "] -version = "2.3.4" +version = "2.3.5" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/src/vector_of_array.jl b/src/vector_of_array.jl index 350e6e21..8a5dd1f0 100644 --- a/src/vector_of_array.jl +++ b/src/vector_of_array.jl @@ -41,8 +41,8 @@ Base.@propagate_inbounds Base.getindex(VA::AbstractDiffEqArray{T, N}, I::Abstrac 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)] Base.@propagate_inbounds function Base.getindex(VA::AbstractVectorOfArray{T,N}, ii::CartesianIndex) where {T, N} ti = Tuple(ii) - i = first(ti) - jj = CartesianIndex(Base.tail(ti)) + i = last(ti) + jj = CartesianIndex(Base.front(ti)) return VA.u[i][jj] end 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} end Base.@propagate_inbounds function Base.setindex!(VA::AbstractVectorOfArray{T,N}, x, ii::CartesianIndex) where {T, N} ti = Tuple(ii) - i = first(ti) - jj = CartesianIndex(Base.tail(ti)) + i = last(ti) + jj = CartesianIndex(Base.front(ti)) return VA.u[i][jj] = x end diff --git a/test/basic_indexing.jl b/test/basic_indexing.jl index a4907c2d..c7a06824 100644 --- a/test/basic_indexing.jl +++ b/test/basic_indexing.jl @@ -75,13 +75,14 @@ testva[1:2, 1:2] # Test broadcast a = testva .+ rand(3,3) -@test_broken a.= testva +a.= testva +@test all(a .== testva) recs = [rand(2,2) for i in 1:5] testva = VectorOfArray(recs) @test Array(testva) isa Array{Float64,3} v = VectorOfArray([zeros(20), zeros(10,10), zeros(3,3,3)]) -v[CartesianIndex((3, 2, 3, 2))] = 1 -@test v[CartesianIndex((3, 2, 3, 2))] == 1 +v[CartesianIndex((2, 3, 2, 3))] = 1 +@test v[CartesianIndex((2, 3, 2, 3))] == 1 @test v.u[3][2, 3, 2] == 1 diff --git a/test/upstream.jl b/test/upstream.jl index 88f2a2e4..03679efd 100644 --- a/test/upstream.jl +++ b/test/upstream.jl @@ -12,6 +12,8 @@ sol = solve(prob,Tsit5()) sol = solve(prob,AutoTsit5(Rosenbrock23(autodiff=false))) sol = solve(prob,AutoTsit5(Rosenbrock23())) +@test all(Array(sol) .== sol) + function f!(F, vars) x = vars.x[1] F.x[1][1] = (x[1]+3)*(x[2]^3-7)+18