allow vcat on single ChainedVector#96
Open
stuartthomas25 wants to merge 1 commit intoJuliaData:mainfrom
Open
Conversation
Formerly, `vcat(a::ChainedVector)` would fail with an error.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #96 +/- ##
==========================================
- Coverage 94.82% 94.73% -0.10%
==========================================
Files 5 5
Lines 1043 1044 +1
==========================================
Hits 989 989
- Misses 54 55 +1 ☔ View full report in Codecov by Sentry. |
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.)
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)would fail with an error. This PR adds a method to match the typical Julia behavior thatvcat(a)=a.