allow vcat on single ChainedVector - #96
Merged
Merged
Conversation
Formerly, `vcat(a::ChainedVector)` would fail with an error.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #96 +/- ##
==========================================
+ Coverage 94.82% 95.64% +0.82%
==========================================
Files 5 5
Lines 1043 1056 +13
==========================================
+ Hits 989 1010 +21
+ Misses 54 46 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
One observation: The typical Julia behavior is that vcat copies its inputs: x = [1,2,3]
vcat(x) === x # falsewhereas here x = ChainedVector([[1,2,3],[4,5]])
vcat(x) === x # true |
ararslan
reviewed
Feb 4, 2025
Comment on lines
632
to
634
| Base.vcat(A::ChainedVector{T, AT}) where {T, AT <: AbstractVector{T}} = A | ||
|
|
||
| function Base.vcat(A::ChainedVector{T, AT}, arrays::ChainedVector{T, AT}...) where {T, AT <: AbstractVector{T}} |
Member
There was a problem hiding this comment.
I'd suggest folding this into the same method, either with a fast path like
Suggested change
| Base.vcat(A::ChainedVector{T, AT}) where {T, AT <: AbstractVector{T}} = A | |
| function Base.vcat(A::ChainedVector{T, AT}, arrays::ChainedVector{T, AT}...) where {T, AT <: AbstractVector{T}} | |
| function Base.vcat(A::ChainedVector{T, AT}, arrays::ChainedVector{T, AT}...) where {T, AT <: AbstractVector{T}} | |
| isempty(arrays) && return Base.unaliascopy(A) |
or by fixing the source of the error directly by passing init=0 to sum a few lines down. (The latter would require bumping the minimum Julia compat to at least 1.6, but IMO that's fine.)
Return a wrapper-preserving copy for one-argument vcat. Teach SentinelArray and nested ChainedVector storage how to make unaliasing copies. Add coverage for identity, mutation isolation, missing and sentinel values, heterogeneous chunks, nesting, and inference.
quinnj
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Formerly,
vcat(a::ChainedVector)failed with an error. This PR makes one-inputvcatreturn an unaliasedChainedVector, matching the typical Julia behavior thatvcat(a) == abutvcat(a) !== a.It also adds wrapper-preserving unaliasing for nested
ChainedVectorandSentinelArraystorage, with regression tests for identity, mutation isolation, missing and sentinel values, heterogeneous chunks, nesting, and inference.Co-authored by Codex