Skip to content

Commit 7c1ef00

Browse files
committed
Revert "Define in for CartesianIndex ranges (#58616)"
This reverts commit 304847e.
1 parent c4e298c commit 7c1ef00

File tree

2 files changed

+0
-72
lines changed

2 files changed

+0
-72
lines changed

base/multidimensional.jl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,6 @@ module IteratorsMD
183183
step(r), ", ", length(r), ")")
184184
end
185185

186-
Base.in(x::CartesianIndex, r::AbstractRange{<:CartesianIndex}) = false
187-
function Base.in(x::CartesianIndex{N}, r::AbstractRange{CartesianIndex{N}}) where {N}
188-
isempty(r) && return false
189-
f, st, l = first(r), step(r), last(r)
190-
# The n-th element of the range is a CartesianIndex
191-
# whose elements are the n-th along each dimension
192-
# Find the first dimension along which the index is changing,
193-
# so that n may be uniquely determined
194-
for i in 1:N
195-
iszero(st[i]) && continue
196-
n = findfirst(==(x[i]), f[i]:st[i]:l[i])
197-
isnothing(n) && return false
198-
return r[n] == x
199-
end
200-
# if the step is zero, the elements are identical, so compare with the first
201-
return x == f
202-
end
203-
204186
# Iteration
205187
const OrdinalRangeInt = OrdinalRange{Int, Int}
206188
"""

test/cartesian.jl

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -573,57 +573,3 @@ end
573573
end
574574
@test t3 == (1, 2, 0)
575575
end
576-
577-
@testset "CartesianIndex show" begin
578-
c = CartesianIndex()
579-
@test sprint(show, c) == "CartesianIndex()"
580-
c = CartesianIndex(3)
581-
@test sprint(show, c) == "CartesianIndex(3)"
582-
c = CartesianIndex(3, 3)
583-
@test sprint(show, c) == "CartesianIndex(3, 3)"
584-
end
585-
586-
@testset "CartesianIndex indexing with begin/end" begin
587-
I = CartesianIndex(3,4)
588-
@test I[begin] == I[1]
589-
@test I[end] == I[2]
590-
end
591-
592-
@testset "in for a CartesianIndex StepRangeLen" begin
593-
@testset for l in [0, 1, 4], r in Any[
594-
StepRangeLen(CartesianIndex(), CartesianIndex(), l),
595-
StepRangeLen(CartesianIndex(1), CartesianIndex(0), l),
596-
StepRangeLen(CartesianIndex(1), CartesianIndex(1), l),
597-
StepRangeLen(CartesianIndex(1), CartesianIndex(4), l),
598-
StepRangeLen(CartesianIndex(1), CartesianIndex(-4), l),
599-
StepRangeLen(CartesianIndex(-1, 2), CartesianIndex(0, 0), l),
600-
StepRangeLen(CartesianIndex(-1, 2), CartesianIndex(0, 4), l),
601-
StepRangeLen(CartesianIndex(-1, 2), CartesianIndex(0, -4), l),
602-
StepRangeLen(CartesianIndex(-1, 2), CartesianIndex(4, 0), l),
603-
StepRangeLen(CartesianIndex(-1, 2), CartesianIndex(-4, 0), l),
604-
StepRangeLen(CartesianIndex(-1, 2), CartesianIndex(4, 2), l),
605-
StepRangeLen(CartesianIndex(-1, 2), CartesianIndex(-4, 2), l),
606-
StepRangeLen(CartesianIndex(-1, 2), CartesianIndex(4, -2), l),
607-
StepRangeLen(CartesianIndex(-1, 2), CartesianIndex(-4, -2), l),
608-
StepRangeLen(CartesianIndex(-1, 2, 0), CartesianIndex(0, 0, 0), l),
609-
StepRangeLen(CartesianIndex(-1, 2, 0), CartesianIndex(0, 0, -2), l),
610-
]
611-
612-
if length(r) == 0
613-
@test !(first(r) in r)
614-
@test !(last(r) in r)
615-
end
616-
for x in r
617-
@test x in r
618-
if step(r) != oneunit(x)
619-
@test !((x + oneunit(x)) in r)
620-
end
621-
end
622-
@test !(CartesianIndex(ntuple(x->0, ndims(r))) in r)
623-
@test !(CartesianIndex(ntuple(x->typemax(Int), ndims(r))) in r)
624-
@test !(CartesianIndex(ntuple(x->typemin(Int), ndims(r))) in r)
625-
if ndims(r) > 1
626-
@test !(CartesianIndex(ntuple(x->0, ndims(r)-1)...) in r)
627-
end
628-
end
629-
end

0 commit comments

Comments
 (0)