Skip to content

Commit 503fb94

Browse files
authored
Define checkindex with AbstractFill only for AbstractInfUnitRange (#220)
* Check for flag before defining checkindex * Add leading underscore * Check `hasmethod` instead of a variable * Define method only for AbstractInfUnitRange * Tests for bounds checking * Fix test
1 parent bb472e3 commit 503fb94

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "InfiniteArrays"
22
uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
3-
version = "0.15.8"
3+
version = "0.15.9"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/infarrays.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ Base._unsafe_getindex(::IndexStyle, A::AbstractFill{<:Any,2}, kr::InfAxes, jr::U
428428

429429
@inline getindex(A::ApplyMatrix{<:Any,typeof(hcat)}, kr::InfAxes, j::Integer) = layout_getindex(A, kr, j)
430430

431-
Base.checkindex(::Type{Bool}, inds::AbstractUnitRange, I::AbstractFill) = Base.checkindex(Bool, inds, getindex_value(I))
431+
Base.checkindex(::Type{Bool}, inds::AbstractInfUnitRange, I::AbstractFill) = Base.checkindex(Bool, inds, getindex_value(I))
432+
Base.checkindex(::Type{Bool}, inds::AbstractInfUnitRange, I::AbstractFill{Bool}) = axes(I,1) == inds
432433
LazyArrays.cache_getindex(::InfiniteCardinal{0}, A::AbstractVector, I, J...) = layout_getindex(A, I, J...)
433434
LazyArrays.cache_getindex(::InfiniteCardinal{0}, A::CachedVector{<:Any,<:AbstractVector,<:AbstractFill{<:Any,1}}, I::AbstractVector) = LazyArrays.cache_getindex(nothing, A, I)
434435

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,14 @@ end
12861286
@test (a*Hcat(Zeros(1,2), permutedims(1:∞)))[1,1:5] == (a*Vcat(Hcat(Zeros(1,2), permutedims(1:∞))))[1,1:5]
12871287
end
12881288

1289+
@testset "checkindex" begin
1290+
r = 1:
1291+
for v in (4, true)
1292+
f = Fill(v, ∞)
1293+
@test checkbounds(Bool, r, f)
1294+
end
1295+
end
1296+
12891297
include("test_infconv.jl")
12901298
include("test_infblock.jl")
12911299
include("test_infbanded.jl")

0 commit comments

Comments
 (0)