From 69c4fc4ac4c4241bdf7b3c9625e45bfd41d7be37 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 16:13:50 +0100 Subject: [PATCH 1/2] PAatial support for indexing infinite padded arrays --- src/infarrays.jl | 21 ++++++++++++--------- test/runtests.jl | 10 ++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/infarrays.jl b/src/infarrays.jl index 1bea288..7c3ccf3 100644 --- a/src/infarrays.jl +++ b/src/infarrays.jl @@ -382,23 +382,26 @@ ArrayLayouts.typed_vcat(::Type{T}, ::Tuple{Any,InfiniteCardinal{0}}, A...) where sub_materialize(_, V, ::Tuple{InfAxes}) = V sub_materialize(_, V, ::Tuple{InfAxes,InfAxes}) = V -sub_materialize(_, V, ::Tuple{<:Any,InfAxes}) = V +sub_materialize(_, V, ::Tuple{Any,InfAxes}) = V sub_materialize(_, V, ::Tuple{InfAxes,Any}) = V sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractVector, ::Tuple{InfAxes}) = ApplyArray(V) -sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{InfAxes,InfAxes}) = ApplyArray(V) -sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{<:Any,InfAxes}) = ApplyArray(V) -sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{InfAxes,Any}) = ApplyArray(V) +sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{InfAxes, InfAxes}) = ApplyArray(V) +sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{Any, InfAxes}) = ApplyArray(V) +sub_materialize(::ApplyLayout{typeof(vcat)}, V::AbstractMatrix, ::Tuple{InfAxes, Any}) = ApplyArray(V) sub_materialize(::ApplyLayout{typeof(hcat)}, V, ::Tuple{InfAxes}) = V -sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{InfAxes,InfAxes}) = ApplyArray(V) -sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{<:Any,InfAxes}) = ApplyArray(V) -sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{InfAxes,Any}) = ApplyArray(V) +sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{InfAxes, InfAxes}) = ApplyArray(V) +sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{Any, InfAxes}) = ApplyArray(V) +sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{InfAxes, Any}) = ApplyArray(V) -sub_materialize(::AbstractPaddedLayout, v::AbstractVector{T}, ::Tuple{InfAxes}) where T = - _padded_sub_materialize(v) +sub_materialize(::AbstractPaddedLayout, v::AbstractVector, ::Tuple{InfAxes}) = _padded_sub_materialize(v) + +sub_materialize(::AbstractPaddedLayout, v::AbstractMatrix, ::Tuple{InfAxes, InfAxes}) = v +sub_materialize(::AbstractPaddedLayout, v::AbstractMatrix, ::Tuple{InfAxes, Any}) = v +sub_materialize(::AbstractPaddedLayout, v::AbstractMatrix, ::Tuple{Any, InfAxes}) = v sub_materialize(lay::InvColumnLayout, v::AbstractVector, ax::Tuple{InfAxes}) = Base.invoke(sub_materialize, Tuple{InvColumnLayout, AbstractVector, Any}, lay, v, ax) diff --git a/test/runtests.jl b/test/runtests.jl index 4175094..d466e15 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1247,6 +1247,16 @@ end @test LazyArrays.sub_materialize(view(v, 2:∞))[1:10] == zeros(10) @test v[2:∞] isa Zeros @test v[1:∞] == v + + V = Vcat([1 2; 3 4], Zeros(∞,2)) + H = Hcat([1 2; 3 4], Zeros(2,∞)) + S = ApplyArray(Base.setindex, Zeros(∞,∞), [1 2; 3 4], Base.OneTo(2), Base.OneTo(2)) + @test_skip V[:,1] == S[:,1] == [1; 3; Zeros(∞)] + @test V[:,1] ≈ S[:,1] ≈ [1; 3; Zeros(∞)] # TODO: change to == + @test V[2:∞,1:2] ≈ S[2:∞,1:2] ≈ Vcat([3 4], Zeros(∞,2)) + @test H[1,:] ≈ S[1,:] ≈ [1; 2; Zeros(∞)] + @test_broken H[1:2,2:∞] ≈ S[1:2,2:∞] ≈ Hcat([2; 4], Zeros(2,∞)) + @test_broken S[2:∞,2:∞] ≈ ApplyArray(Base.setindex, Zeros(∞,∞), 4, 1, 1) end @testset "issue #180" begin From ad0bcfd070c0dff3587521aac388bda01ba16f70 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 16:14:06 +0100 Subject: [PATCH 2/2] v0.15.8 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index f4d4af3..166208d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "InfiniteArrays" uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c" -version = "0.15.7" +version = "0.15.8" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"