From e3e3bd76f0d1899488cc96975741b8befa7cfb53 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Tue, 14 Oct 2025 17:54:03 +0200 Subject: [PATCH 1/4] Implement `Base.resize!` for `ArrayPartition`s --- src/array_partition.jl | 6 ++++++ test/partitions_test.jl | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/array_partition.jl b/src/array_partition.jl index 89261f4b..4898b741 100644 --- a/src/array_partition.jl +++ b/src/array_partition.jl @@ -124,6 +124,12 @@ Base.ones(A::ArrayPartition, dims::NTuple{N, Int}) where {N} = ones(A) return :($res) end +## resize! +function Base.resize!(A::ArrayPartition, sizes::Tuple) + resize!.(A.x, sizes) + A +end + ## vector space operations for op in (:+, :-) diff --git a/test/partitions_test.jl b/test/partitions_test.jl index 3c0c2232..3b915c58 100644 --- a/test/partitions_test.jl +++ b/test/partitions_test.jl @@ -60,6 +60,10 @@ copyto!(p, c) @test c[1:5] == p.x[1] @test c[6:10] == p.x[2] +resize!(p, (6, 7)) +@test length(p.x[1]) == 6 +@test length(p.x[2]) == 7 + ## inference tests x = ArrayPartition([1, 2], [3.0, 4.0]) From 9f06021f6646fbeb31a46cb6b544f58648fd5dd3 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Fri, 17 Oct 2025 08:24:46 -0400 Subject: [PATCH 2/4] Add issparse method for AbstractVectorOfArray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #486 When issparse(::SubArray) is called, it tries to call issparse on the parent array. If the parent is an AbstractVectorOfArray, there was no issparse method defined, causing a MethodError. This commit adds issparse method that returns false for AbstractVectorOfArray, since it is not a sparse array type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- ext/RecursiveArrayToolsSparseArraysExt.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/RecursiveArrayToolsSparseArraysExt.jl b/ext/RecursiveArrayToolsSparseArraysExt.jl index 929f63f5..a8ed047d 100644 --- a/ext/RecursiveArrayToolsSparseArraysExt.jl +++ b/ext/RecursiveArrayToolsSparseArraysExt.jl @@ -18,4 +18,8 @@ function Base.copyto!( dest end +# Fix for issue #486: Define issparse for AbstractVectorOfArray +# AbstractVectorOfArray is not a sparse array type, so it should return false +SparseArrays.issparse(::RecursiveArrayTools.AbstractVectorOfArray) = false + end From a0728c27196aae571adeb85d811c0b04816861ad Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Fri, 17 Oct 2025 08:25:27 -0400 Subject: [PATCH 3/4] Add tests for issparse method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds comprehensive tests for the issparse method including: - Testing issparse returns false for VectorOfArray - Testing issparse returns false for DiffEqArray - Testing the original issue with SubArray views - Testing nested VectorOfArray structures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- test/interface_tests.jl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/interface_tests.jl b/test/interface_tests.jl index 3384848a..18b8853d 100644 --- a/test/interface_tests.jl +++ b/test/interface_tests.jl @@ -303,3 +303,24 @@ end darr = DiffEqArray([ones(2)], [1.0], :params, :sys) @test darr.sys == :sys end + +@testset "issparse for AbstractVectorOfArray (issue #486)" begin + using SparseArrays + + # Test that issparse returns false for VectorOfArray + testva = VectorOfArray([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) + @test issparse(testva) == false + + # Test that issparse returns false for DiffEqArray + testda = DiffEqArray([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 1:3) + @test issparse(testda) == false + + # Test the original issue: issparse should work with SubArray views + # This was failing before because issparse(::SubArray) calls issparse on the parent + testview = view(testva, :, :) + @test issparse(testview) == false + + # Test with nested VectorOfArray + nested_voa = VectorOfArray([testva, testva]) + @test issparse(nested_voa) == false +end From 88b0c97cc7ebb2ded41ef5108f8832fc56e2c9ed Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 17 Oct 2025 08:59:12 -0400 Subject: [PATCH 4/4] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 689ed564..3f40f0ec 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RecursiveArrayTools" uuid = "731186ca-8d62-57ce-b412-fbd966d074cd" authors = ["Chris Rackauckas "] -version = "3.38.0" +version = "3.39.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"