Skip to content

Commit d848bfb

Browse files
Merge pull request #490 from ChrisRackauckas-Claude/fix-issparse-486
Fix issparse for AbstractVectorOfArray
2 parents 537a78e + a0728c2 commit d848bfb

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

ext/RecursiveArrayToolsSparseArraysExt.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ function Base.copyto!(
1818
dest
1919
end
2020

21+
# Fix for issue #486: Define issparse for AbstractVectorOfArray
22+
# AbstractVectorOfArray is not a sparse array type, so it should return false
23+
SparseArrays.issparse(::RecursiveArrayTools.AbstractVectorOfArray) = false
24+
2125
end

test/interface_tests.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,24 @@ end
303303
darr = DiffEqArray([ones(2)], [1.0], :params, :sys)
304304
@test darr.sys == :sys
305305
end
306+
307+
@testset "issparse for AbstractVectorOfArray (issue #486)" begin
308+
using SparseArrays
309+
310+
# Test that issparse returns false for VectorOfArray
311+
testva = VectorOfArray([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
312+
@test issparse(testva) == false
313+
314+
# Test that issparse returns false for DiffEqArray
315+
testda = DiffEqArray([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 1:3)
316+
@test issparse(testda) == false
317+
318+
# Test the original issue: issparse should work with SubArray views
319+
# This was failing before because issparse(::SubArray) calls issparse on the parent
320+
testview = view(testva, :, :)
321+
@test issparse(testview) == false
322+
323+
# Test with nested VectorOfArray
324+
nested_voa = VectorOfArray([testva, testva])
325+
@test issparse(nested_voa) == false
326+
end

0 commit comments

Comments
 (0)