Skip to content

Commit 616e8fc

Browse files
Remove similar(::VectorOfArray, ::Integer) to eliminate 469-child invalidation
This method conflicted with AbstractArray's similar(a, dims...) contract and caused 469 invalidation children. Users should use standard similar(VA, T, dims) or construct VectorOfArrays directly. Invalidation trees: 4 → 3 (and 0 from AbstractVectorOfArray itself — all 3 remaining are pre-existing from ArrayPartition/NamedArrayPartition) Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1dfc71c commit 616e8fc

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

src/vector_of_array.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,15 +1074,7 @@ end
10741074
return similar(Array{T}, dims)
10751075
end
10761076

1077-
# similar(VA, dims::Int) - create VectorOfArray with given number of inner arrays
1078-
@inline function Base.similar(VA::VectorOfArray, dims::Integer)
1079-
l = length(VA.u)
1080-
return if dims <= l
1081-
VectorOfArray(similar.(VA.u[1:dims]))
1082-
else
1083-
VectorOfArray([similar.(VA.u); [similar(VA.u[end]) for _ in (l + 1):dims]])
1084-
end
1085-
end
1077+
## similar(VA, dims) inherited from AbstractArray (returns Array)
10861078

10871079
# fill!
10881080
# For DiffEqArray it ignores ts and fills only u

test/interface_tests.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ testva2 = similar(testva)
160160
@test typeof(testva2) == typeof(testva)
161161
@test size(testva2) == size(testva)
162162

163+
# similar(VA, dims) returns a regular Array (AbstractArray behavior)
163164
testva3 = similar(testva, 10)
164-
@test typeof(testva3) == typeof(testva)
165-
@test length(testva3.u) == 10 # 10 inner arrays
165+
@test testva3 isa Vector{Float64}
166+
@test length(testva3) == 10
166167

167168
# Fill AbstractVectorOfArray and check all
168169
testval = 3.0

0 commit comments

Comments
 (0)