From 9f06021f6646fbeb31a46cb6b544f58648fd5dd3 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Fri, 17 Oct 2025 08:24:46 -0400 Subject: [PATCH 1/2] 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 2/2] 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