From 0188af20ed0574a66e6a3f74bd17665322de447d Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Fri, 26 Feb 2021 11:27:15 +0000 Subject: [PATCH 1/4] tests pass --- Project.toml | 4 ++-- src/infrange.jl | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index bb25596..fd5c716 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "InfiniteArrays" uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c" -version = "0.10.2" +version = "0.10.3" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" @@ -16,7 +16,7 @@ ArrayLayouts = "0.5, 0.6" DSP = "0.6" FillArrays = "0.11" Infinities = "0.0.2" -LazyArrays = "0.20.5" +LazyArrays = "0.20.5, 0.21" julia = "1.5" [extras] diff --git a/src/infrange.jl b/src/infrange.jl index 125ebe7..b16590c 100644 --- a/src/infrange.jl +++ b/src/infrange.jl @@ -583,4 +583,7 @@ for op in (:isequal, :(==)) findfirst(p::Fix2{typeof($op),<:Number}, r::InfStepRange{<:Integer,<:Integer}) = isinteger(p.x) ? findfirst($op(convert(V, p.x)), r) : nothing end -end \ No newline at end of file +end + + +FillArrays._range_convert(::Type{AbstractVector{T}}, r::InfRanges) where T = convert(AbstractVector{T}, r) \ No newline at end of file From 3ae1d432e183da7b213ecaabd623e53aabb244b4 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Fri, 26 Feb 2021 11:41:44 +0000 Subject: [PATCH 2/4] use cache_getindex --- src/infarrays.jl | 10 +++++++--- test/runtests.jl | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/infarrays.jl b/src/infarrays.jl index 00dbaee..935ecde 100644 --- a/src/infarrays.jl +++ b/src/infarrays.jl @@ -257,6 +257,10 @@ _unsafe_getindex(::IndexLinear, A::Vcat, r::InfUnitRange) = _vcat(_gettail(first getindex(A::AbstractVector, r::InfRanges{<:Integer}) = layout_getindex(A, r) getindex(A::LayoutVector, r::InfRanges{<:Integer}) = layout_getindex(A, r) -getindex(A::AbstractCachedVector, r::InfRanges{<:Integer}) = layout_getindex(A, r) -getindex(A::CachedVector{<:Any,<:AbstractVector,<:AbstractFill{<:Any,1}}, r::InfRanges{<:Integer}) = layout_getindex(A, r) -getindex(A::AbstractFill{<:Any,1}, r::InfRanges{<:Integer}) = FillArrays.fillsimilar(A, length(r)) \ No newline at end of file +getindex(A::CachedVector, r::InfRanges{<:Integer}) = layout_getindex(A, r) +getindex(A::AbstractFill{<:Any,1}, r::InfRanges{<:Integer}) = FillArrays.fillsimilar(A, length(r)) + + +Base.checkindex(::Type{Bool}, inds::AbstractUnitRange, I::AbstractFill) = Base.checkindex(Bool, inds, getindex_value(I)) +LazyArrays.cache_getindex(::InfiniteCardinal{0}, A::AbstractVector, I, J...) = layout_getindex(A, I, J...) + diff --git a/test/runtests.jl b/test/runtests.jl index 2f4c409..db6b726 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -893,4 +893,8 @@ end AbstractMatrix{Float64}(transpose(1:∞)) ≡ AbstractMatrix{Float64}(transpose(oneto(∞))) ≡ AbstractArray{Float64}(transpose(1:∞)) ≡ AbstractArray{Float64}(transpose(oneto(∞))) ≡ transpose(InfUnitRange(1.0)) +end + +@testset "cached indexing" begin + @test cache(1:∞)[Fill(2,∞)][1:10] == fill(2,10) end \ No newline at end of file From e2ad85df1bcd12a307e1e7abe07637068bcad4ea Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Fri, 26 Feb 2021 14:02:57 +0000 Subject: [PATCH 3/4] Update Project.toml --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index fd5c716..158bdfc 100644 --- a/Project.toml +++ b/Project.toml @@ -12,11 +12,11 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] -ArrayLayouts = "0.5, 0.6" +ArrayLayouts = "0.6" DSP = "0.6" FillArrays = "0.11" Infinities = "0.0.2" -LazyArrays = "0.20.5, 0.21" +LazyArrays = "0.21" julia = "1.5" [extras] From 29e3ec234891e61fc65d768f3e1f85406cd46a9c Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Sun, 28 Feb 2021 21:03:19 +0000 Subject: [PATCH 4/4] increase coverage --- Project.toml | 2 +- test/runtests.jl | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 158bdfc..f86f6f9 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,7 @@ ArrayLayouts = "0.6" DSP = "0.6" FillArrays = "0.11" Infinities = "0.0.2" -LazyArrays = "0.21" +LazyArrays = "0.21.1" julia = "1.5" [extras] diff --git a/test/runtests.jl b/test/runtests.jl index db6b726..503b637 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -54,8 +54,16 @@ import Base.Broadcast: broadcasted, Broadcasted, instantiate @test similar(a, Float64, (2,∞)) isa CachedArray{Float64} @test similar(a, Float64, (∞,2)) isa CachedArray{Float64} + + @test similar(Array{Float64}, (∞,)) isa CachedArray{Float64} + @test similar(Array{Float64}, (∞,∞)) isa CachedArray{Float64} @test similar(Array{Float64}, (2,∞)) isa CachedArray{Float64} @test similar(Array{Float64}, (∞,2)) isa CachedArray{Float64} + + @test similar(Array{Float64}, (oneto(∞),)) isa CachedArray{Float64} + @test similar(Array{Float64}, (oneto(∞),oneto(∞))) isa CachedArray{Float64} + @test similar(Array{Float64}, (oneto(∞),oneto(5))) isa CachedArray{Float64} + @test similar(Array{Float64}, (oneto(5),oneto(∞))) isa CachedArray{Float64} end @testset "zeros/fill/ones" begin @@ -83,6 +91,10 @@ import Base.Broadcast: broadcasted, Broadcasted, instantiate @test ones(5,∞)[:,1:10] == ones(5,10) @test ones(∞,5)[1:10,:] == ones(10,5) @test ones(∞,∞)[1:5,1:5] == ones(5,5) + + @test zeros(∞, 5)[1:10,:] == zeros(10,5) + @test zeros(Int, ∞, 5)[1:10,:] == zeros(10,5) + @test zeros(Int, 5, ∞)[:,1:10] == zeros(5, 10) end end @@ -490,6 +502,13 @@ end @test @inferred(broadcast(*,Ones(∞)',D)) == @inferred(broadcast(*,D,Ones(∞)')) == Diagonal(1.0:∞) @test @inferred(broadcast(*,Fill(2,∞)',D)) ≡ @inferred(broadcast(*,D,Fill(2,∞)')) ≡ 2D + @test Eye{Int}(∞, ∞) isa Eye{Int} + @test Eye{Int}(∞, 5) isa Eye{Int} + @test Eye{Int}(5, ∞) isa Eye{Int} + @test Eye(∞, ∞) isa Eye{Float64} + @test Eye(∞, 5) isa Eye{Float64} + @test Eye(5, ∞) isa Eye{Float64} + @test Eye{Int}(∞) * D ≡ Eye{Int}(∞) * D ≡ D @test Eye(∞) * D == Eye(∞) * D == D end