From 6fbaff13691b9895948d1a46cea1c45062a8093d Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 7 Sep 2020 13:58:45 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Fix=20a[:]=20for=20=E2=88=9E=20Vcat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project.toml | 2 +- src/InfiniteArrays.jl | 6 +++++- test/runtests.jl | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 3f7f9af..71806ee 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] DSP = "0.6" FillArrays = "0.9.4" -LazyArrays = "0.17.3, 0.18" +LazyArrays = "0.18.1" julia = "1.5" [extras] diff --git a/src/InfiniteArrays.jl b/src/InfiniteArrays.jl index fd045cf..92bdc92 100644 --- a/src/InfiniteArrays.jl +++ b/src/InfiniteArrays.jl @@ -39,7 +39,7 @@ import Statistics: mean, median import FillArrays: AbstractFill, getindex_value, fill_reshape, RectDiagonal import LazyArrays: LazyArrayStyle, AbstractBandedLayout, MemoryLayout, LazyLayout, UnknownLayout, - ZerosLayout, AbstractArrayApplyStyle, CachedArray, CachedVector, + ZerosLayout, AbstractArrayApplyStyle, CachedArray, CachedVector, ApplyLayout, reshapedlayout, sub_materialize, LayoutMatrix, LayoutVector, _padded_sub_materialize, PaddedLayout import DSP: conv @@ -228,6 +228,10 @@ sub_materialize(_, V, ::Tuple{InfAxes,InfAxes}) = V sub_materialize(_, V, ::Tuple{<:Any,InfAxes}) = V sub_materialize(_, V, ::Tuple{InfAxes,Any}) = 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(::PaddedLayout, v::AbstractVector{T}, ::Tuple{InfAxes}) where T = _padded_sub_materialize(v) diff --git a/test/runtests.jl b/test/runtests.jl index f532320..1a3b77d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -710,6 +710,14 @@ end @test Base.copymutable(Vcat([1.,2.], zeros(∞))) isa CachedArray @test Base.copymutable(Vcat(1.,2., zeros(∞))) isa CachedArray end + + @testset "colon" begin + a = Vcat(1, 1:∞) + a[:] + + A = Vcat(Ones(1,∞), Fill(2,1,∞)) + @test A[:,:] == A + end end @testset "broadcasting" begin From 8bd074aa71ac74834e757eaacce8e83c98142d65 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Tue, 8 Sep 2020 14:59:42 +0100 Subject: [PATCH 2/4] Update runtests.jl --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 1a3b77d..4da6dee 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -699,7 +699,7 @@ end @test colsupport(A,1) == 1:1 @test Base.replace_in_print_matrix(A, 2, 1, "0") == "⋅" @test stringmime("text/plain", A; context=(:limit => true)) == - "∞-element ApplyArray{Float64,1,typeof(vcat),Tuple{$Int,Zeros{Float64,1,Tuple{OneToInf{$Int}}}}} with indices OneToInf():\n 1.0\n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋮" + "vcat($Int, ∞-element Zeros{Float64,1,Tuple{OneToInf{$Int}}} with indices OneToInf()) with indices OneToInf():\n 1.0\n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋅ \n ⋮" A = Vcat(Ones{Int}(1,∞), Diagonal(1:∞)) @test Base.replace_in_print_matrix(A, 2, 2, "0") == "⋅" end From 8271f857288be6934774a55a667b691d4add3b81 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Wed, 9 Sep 2020 09:21:42 +0100 Subject: [PATCH 3/4] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 71806ee..768c9b0 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] DSP = "0.6" -FillArrays = "0.9.4" +FillArrays = "0.9.6" LazyArrays = "0.18.1" julia = "1.5" From 1bcf810664f0441963b2e8ade934ace0d71c0ec1 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Wed, 9 Sep 2020 09:49:09 +0100 Subject: [PATCH 4/4] Update runtests.jl --- test/runtests.jl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 4da6dee..233e1ce 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -711,12 +711,24 @@ end @test Base.copymutable(Vcat(1.,2., zeros(∞))) isa CachedArray end - @testset "colon" begin + @testset "infinite indexing" begin a = Vcat(1, 1:∞) - a[:] + @test a[:] isa Vcat + @test a[3:∞] ≡ 2:∞ + @test a[3:2:∞] isa Vcat A = Vcat(Ones(1,∞), Fill(2,1,∞)) @test A[:,:] == A + @test A[:,2:∞] isa Vcat + + A = Vcat(Ones(5,5), Fill(2,∞,5)) + @test A[:,:] == A + @test A[2:∞,:] isa Vcat + + A = Vcat(Ones(1,∞), Fill(2,∞,∞)) + @test A[:,:] == A + @test A[2:∞,2:∞] isa Vcat + @test A[2:∞,2:∞][1:10,1:10] == fill(2,10,10) end end