Skip to content

Commit 37759b8

Browse files
authored
add deprecated message for ±(x::CartesianIndex, y) (#101)
1 parent 2651452 commit 37759b8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/interval.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ Construct a ClosedInterval `iv` spanning the region from
9292
`center - halfwidth` to `center + halfwidth`.
9393
"""
9494
±(x, y) = ClosedInterval(x - y, x + y)
95-
±(x::CartesianIndex, y) = (xy = y * one(x); map(ClosedInterval, (x - xy).I, (x + xy).I))
95+
function ±(x::CartesianIndex, y)
96+
# TODO: Remove this method in the next breaking release
97+
Base.depwarn("This method for `CartesianIndex(1,2) ± 1 == (0..2, 1..3)` is not consistent and will be removed because CartesianIndex(1,1) + 1 is not defined. " *
98+
"If you need tuple such as `(0..2, 1..3)` from `CartesianIndex`, just write it in a plain tuple form.", :±)
99+
(xy = y * one(x); map(ClosedInterval, (x - xy).I, (x + xy).I))
100+
end
96101
±(x::CartesianIndex, y::CartesianIndex) = ClosedInterval(x-y, x+y)
97102

98103
show(io::IO, I::ClosedInterval) = print(io, leftendpoint(I), "..", rightendpoint(I))

0 commit comments

Comments
 (0)