From 4641624bb55a1aacbb3fc12c800e22c620ffc6c6 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 20 Nov 2025 10:43:50 +0000 Subject: [PATCH 1/5] Clearer sublayout for concat --- src/lazyconcat.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lazyconcat.jl b/src/lazyconcat.jl index 04d640dc..33cf2527 100644 --- a/src/lazyconcat.jl +++ b/src/lazyconcat.jl @@ -791,10 +791,16 @@ end # subarrays ### -sublayout(::ApplyLayout{typeof(vcat)}, ::Type{<:Tuple{Vararg{Union{AbstractRange{Int},Int}}}}) = ApplyLayout{typeof(vcat)}() -sublayout(::ApplyLayout{typeof(hcat)}, ::Type{<:Tuple{Vararg{Union{AbstractRange{Int},Int}}}}) = ApplyLayout{typeof(hcat)}() +sublayout(::ApplyLayout{typeof(vcat)}, ::Type{<:Tuple{AbstractRange{Int}}}) = ApplyLayout{typeof(vcat)}() +sublayout(::ApplyLayout{typeof(vcat)}, ::Type{<:Tuple{AbstractRange{Int},Int}}) = ApplyLayout{typeof(vcat)}() +sublayout(::ApplyLayout{typeof(vcat)}, ::Type{<:Tuple{AbstractRange{Int},AbstractRange{Int}}}) = ApplyLayout{typeof(vcat)}() +sublayout(::ApplyLayout{typeof(vcat)}, ::Type{<:Tuple{Int,AbstractRange{Int}}}) = ApplyLayout{typeof(vcat)}() # a Vcat but with only 1 argument + + # a row-slice of an Hcat is equivalent to a Vcat sublayout(::ApplyLayout{typeof(hcat)}, ::Type{<:Tuple{Int,AbstractRange{Int}}}) = ApplyLayout{typeof(vcat)}() +sublayout(::ApplyLayout{typeof(hcat)}, ::Type{<:Tuple{AbstractRange{Int},Int}}) = ApplyLayout{typeof(hcat)}() +sublayout(::ApplyLayout{typeof(hcat)}, ::Type{<:Tuple{AbstractRange{Int},AbstractRange{Int}}}) = ApplyLayout{typeof(hcat)}() _vcat_lastinds(sz) = _vcat_cumsum(sz...) _vcat_firstinds(sz) = (1, (1 .+ Base.front(_vcat_lastinds(sz)))...) From e0283fb59efd279200e797ce05fc308feafea588 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 20 Nov 2025 10:56:28 +0000 Subject: [PATCH 2/5] special case for row view of Vcat --- src/lazyconcat.jl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lazyconcat.jl b/src/lazyconcat.jl index 33cf2527..e03382ee 100644 --- a/src/lazyconcat.jl +++ b/src/lazyconcat.jl @@ -822,13 +822,25 @@ function _vcat_sub_arguments(lay::ApplyLayout{typeof(vcat)}, A, V, kr) _reverse_if_neg_step(map(_view_vcat, arguments(lay, A), skr2), kr) end -function _vcat_sub_arguments(::ApplyLayout{typeof(vcat)}, A, V, kr, jr) - sz = size.(arguments(A),1) +function _vcat_sub_arguments(lay::ApplyLayout{typeof(vcat)}, A, V, kr, jr) + sz = size.(arguments(lay, A),1) skr = intersect.(_argsindices(sz), Ref(kr)) skr2 = broadcast((a,b) -> a .- b .+ 1, skr, _vcat_firstinds(sz)) _reverse_if_neg_step(_view_vcat.(arguments(A), skr2, Ref(jr)), kr) end +function _vcat_sub_arguments(lay::ApplyLayout{typeof(vcat)}, A, V, k::Int, jr) + args = arguments(lay, A) + sz = size.(args,1) + for (a,inds, firstind) in zip(args, _argsindices(sz), _vcat_firstinds(sz)) + if k in inds + return (_view_vcat(a, k - firstind + 1, jr),) + end + end + + () # no args +end + _vcat_sub_arguments(LAY::ApplyLayout{typeof(vcat)}, A, V) = _vcat_sub_arguments(LAY, A, V, parentindices(V)...) From df9bc0386bcaaa14ef315664afa5712b76415f11 Mon Sep 17 00:00:00 2001 From: Daniel VandenHeuvel <95613936+DanielVandH@users.noreply.github.com> Date: Thu, 20 Nov 2025 13:20:52 +0000 Subject: [PATCH 3/5] Add a test --- test/concattests.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/concattests.jl b/test/concattests.jl index 7b5b3e55..087a1bd2 100644 --- a/test/concattests.jl +++ b/test/concattests.jl @@ -698,6 +698,15 @@ import LazyArrays: MemoryLayout, DenseColumnMajor, materialize!, call, paddeddat @test copy(view(V,2:-1:1,1:-1:1)) == [2 ; 1 ;;] @test copy(view(H,1:-1:1,2:-1:1)) == [2 1] end + + @testset "Vcat arguments with integer-range view" begin + A = Vcat([1, 2, 3, 4, 5]', [6, 7, 8, 9, 10]') + V = view(A, 1, 1:3) + args = arguments(V) + @test length(args) == 1 + @test args[1] == [1, 2, 3] + @test args[1] isa SubArray{Int, 1, Vector{Int}} + end end end # module From 4fadc9872c26e4183d0154d7235d5ad2839d120d Mon Sep 17 00:00:00 2001 From: Daniel VandenHeuvel <95613936+DanielVandH@users.noreply.github.com> Date: Mon, 24 Nov 2025 21:05:41 +0000 Subject: [PATCH 4/5] Case where k is not in args range --- test/concattests.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/concattests.jl b/test/concattests.jl index 087a1bd2..97a64de7 100644 --- a/test/concattests.jl +++ b/test/concattests.jl @@ -706,6 +706,9 @@ import LazyArrays: MemoryLayout, DenseColumnMajor, materialize!, call, paddeddat @test length(args) == 1 @test args[1] == [1, 2, 3] @test args[1] isa SubArray{Int, 1, Vector{Int}} + + args = LazyArrays._vcat_sub_arguments(MemoryLayout(V), V, (), 0, 1:3) + @test args == () end end From 734dba1546591c20dce6036ada085da4e4fd44a2 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Tue, 25 Nov 2025 12:33:15 +0000 Subject: [PATCH 5/5] v2.9.2 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 69d57617..561d88f8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "LazyArrays" uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02" -version = "2.9.1" +version = "2.9.2" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"