Skip to content

Commit d9f862f

Browse files
authored
Fast bounds-check for infinite CartesianIndex StepRangeLen (#190)
* Fast bounds-check for infinite CartesianIndex StepRangeLen * Bump version to v0.14.3
1 parent 83860f6 commit d9f862f

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
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.14.2"
3+
version = "0.14.3"
44

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

src/infrange.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,4 +624,9 @@ function inv(D::Diagonal{<:Any, <:InfRanges})
624624
idx = findfirst(iszero, d)
625625
isnothing(idx) || throw(SingularException(idx))
626626
return Diagonal(inv.(d))
627-
end
627+
end
628+
629+
# bounds-checking
630+
function Base.checkindex(::Type{Bool}, inds::NTuple{N, AbstractInfUnitRange}, i::AbstractRange{CartesianIndex{N}}) where {N}
631+
isempty(i) | checkindex(Bool, inds, first(i))
632+
end

test/runtests.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,4 +1230,11 @@ end
12301230
end
12311231

12321232
include("test_infconv.jl")
1233-
include("test_block.jl")
1233+
include("test_block.jl")
1234+
1235+
@testset "bounds-checking for StepRangeLen{<:CartesianIndex}" begin
1236+
if VERSION >= v"1.11.0-rc3"
1237+
D = Diagonal(1:∞)
1238+
@test checkbounds(Bool, D, diagind(D, IndexCartesian()))
1239+
end
1240+
end

0 commit comments

Comments
 (0)