Repository navigation
Concatenate scalars with layout arrays via typed_vcat/typed_hcat - #286
Merged
Merged
Conversation
…ped_hcat [2; v] with v a layout array previously fell back to Base's generic cat, which for infinite lazy arrays hangs trying to copy v. Route one or two scalar prefixes through ArrayLayouts.typed_vcat/typed_hcat so packages like InfiniteArrays can return a lazy Vcat/Hcat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #286 +/- ##
==========================================
+ Coverage 90.33% 90.56% +0.23%
==========================================
Files 12 12
Lines 1987 2036 +49
==========================================
+ Hits 1795 1844 +49
Misses 192 192 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
[2; v]withva layout array (e.g.BandedMatrix(1 => 1:∞)[band(1)]orview(A, 2:∞, 2)) dispatched to Base's genericcat, which never reaches theArrayLayouts.typed_vcat(T, size, A...)hook. For infinite lazy arrays this hangs, because the result is allocated as azeros(∞)cache andvis copied into it, whereas[[2]; v]already gives a lazyVcat.This PR adds
Base.typed_vcat/Base.typed_hcatmethods for one or two scalars followed by aLayoutVecOrMats, routing them through the existing hook. The finite fallback usesBase._cat_twhen scalars are present (as Base does), so finite results are unchanged.With InfiniteArrays, the following now all return a lazy
Vcatinstead of hanging:[2; v],[2; 3; v],vcat(2, v),[2; view(A, band(1))],[2; view(B, 2:∞, 2)],[2; cumsum(1:∞)],[2; (1:∞).^2],[2 view(B, 2:2, 2:∞)].Merge after JuliaArrays/InfiniteArrays.jl#244: without it,
[1; 2; zeros(Int,∞)]would become aVcatrather than aCachedArray, failing an InfiniteArrays test. With both, the InfiniteArrays and LazyArrays test suites pass.Not covered: mixed prefixes such as
[1.0; 2:3; v]still take the generic path (as[[1]; [2]; v]already does).🤖 Generated with Claude Code