From 00af40fe58598690bcebd4bfa540db039dd03a08 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 25 Jul 2024 10:52:38 +0100 Subject: [PATCH] Retain padded structure with infinite indexing (#189) * Retain padded structure with infinite indexing * v0.14.2 --- Project.toml | 2 +- src/infarrays.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7b681af..9829fb6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "InfiniteArrays" uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c" -version = "0.14.1" +version = "0.14.2" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/infarrays.jl b/src/infarrays.jl index 04a6782..6576282 100644 --- a/src/infarrays.jl +++ b/src/infarrays.jl @@ -403,6 +403,8 @@ sub_materialize(lay::InvColumnLayout, v::AbstractVector, ax::Tuple{InfAxes}) = Base._unsafe_getindex(::IndexStyle, A::AbstractVector, r::InfAxes) = layout_getindex(A, r) Base._unsafe_getindex(::IndexStyle, A::AbstractFill{<:Any,1}, r::InfAxes) = FillArrays._fill_getindex(A, r) getindex(A::AbstractCachedVector, r::InfAxes) = layout_getindex(A, r) +# preserve padded/fill structure +getindex(A::CachedVector{<:Any,<:AbstractVector,<:AbstractFill{<:Any,1}}, r::InfAxes) = LazyArrays.cache_getindex(A, r) # don't resize to ∞ Base.isassigned(A::AbstractCachedVector, r::InfiniteCardinal{0}) = true getindex(A::AbstractCachedVector, r::InfiniteCardinal{0}) = A.array[r] @@ -421,4 +423,5 @@ Base._unsafe_getindex(::IndexStyle, A::AbstractFill{<:Any,2}, kr::InfAxes, jr::U 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...) +LazyArrays.cache_getindex(::InfiniteCardinal{0}, A::CachedVector{<:Any,<:AbstractVector,<:AbstractFill{<:Any,1}}, I::AbstractVector) = LazyArrays.cache_getindex(nothing, A, I)