From bc62b560d3b9c931c073564c2165f058476a7902 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 22 Feb 2021 13:53:14 +0000 Subject: [PATCH] Avoid ambiguity warning in cachedvector getindex (#64) * Avoid ambiguity warning in cachedvector getindex * add tests --- Project.toml | 2 +- src/InfiniteArrays.jl | 2 +- src/infarrays.jl | 2 ++ test/runtests.jl | 4 ++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index fe12b90..bb25596 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "InfiniteArrays" uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c" -version = "0.10.1" +version = "0.10.2" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/InfiniteArrays.jl b/src/InfiniteArrays.jl index 92f2808..18768ce 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, Fill, Ones, Zeros, Eye import LazyArrays: LazyArrayStyle, AbstractBandedLayout, MemoryLayout, LazyLayout, UnknownLayout, - ZerosLayout, AbstractArrayApplyStyle, CachedArray, CachedVector, ApplyLayout, LazyMatrix, + ZerosLayout, AbstractArrayApplyStyle, AbstractCachedVector, CachedArray, CachedVector, ApplyLayout, LazyMatrix, reshapedlayout, sub_materialize, LayoutMatrix, LayoutVector, _padded_sub_materialize, PaddedLayout import DSP: conv diff --git a/src/infarrays.jl b/src/infarrays.jl index accec64..00dbaee 100644 --- a/src/infarrays.jl +++ b/src/infarrays.jl @@ -257,4 +257,6 @@ _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 diff --git a/test/runtests.jl b/test/runtests.jl index 59cc82d..2f4c409 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -583,6 +583,10 @@ end @test [[1,2]; [3,4]; [5,6]; Zeros(∞)] isa Vcat{<:Any,1,<:Tuple{Array,Zeros}} @test [randn(2,2); Zeros(∞,2)] isa Vcat{<:Any,2,<:Tuple{Array,Zeros}} + + a = [[1,2,3]; zeros(Int,∞)] + @test a[3:∞][1:5] == a[3:7] + @test cache(1:∞)[2:∞][1:5] == 2:6 end @testset "sparse print" begin