Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast bounds-check for infinite CartesianIndex StepRangeLen #190

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "InfiniteArrays"
uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
version = "0.14.2"
version = "0.14.3"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
7 changes: 6 additions & 1 deletion src/infrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -624,4 +624,9 @@
idx = findfirst(iszero, d)
isnothing(idx) || throw(SingularException(idx))
return Diagonal(inv.(d))
end
end

# bounds-checking
function Base.checkindex(::Type{Bool}, inds::NTuple{N, AbstractInfUnitRange}, i::AbstractRange{CartesianIndex{N}}) where {N}
isempty(i) | checkindex(Bool, inds, first(i))

Check warning on line 631 in src/infrange.jl

View check run for this annotation

Codecov / codecov/patch

src/infrange.jl#L630-L631

Added lines #L630 - L631 were not covered by tests
end
9 changes: 8 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1230,4 +1230,11 @@ end
end

include("test_infconv.jl")
include("test_block.jl")
include("test_block.jl")

@testset "bounds-checking for StepRangeLen{<:CartesianIndex}" begin
if VERSION >= v"1.11.0-rc3"
D = Diagonal(1:∞)
@test checkbounds(Bool, D, diagind(D, IndexCartesian()))
end
end
Loading