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" 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 diff --git a/src/array_partition.jl b/src/array_partition.jl index 5eb1289a..491abfe2 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/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 diff --git a/test/partitions_test.jl b/test/partitions_test.jl index 27abfaf6..2487dbdb 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])