File tree Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -587,6 +587,9 @@ Library improvements
587
587
collection ` A ` . There are also two other methods with a different API, and
588
588
a mutating variant, ` replace! ` ([ #22324 ] ).
589
589
590
+ * Adding integers to ` CartesianIndex ` objects is now deprecated. Instead of
591
+ ` i::Int + x::CartesianIndex ` , use ` i*one(x) + x ` ([ #26284 ] ).
592
+
590
593
* ` CartesianRange ` changes ([ #24715 ] ):
591
594
- Inherits from ` AbstractArray ` , and linear indexing can be used to provide
592
595
linear-to-cartesian conversion ([ #24715 ] )
Original file line number Diff line number Diff line change @@ -1422,6 +1422,12 @@ end
1422
1422
@deprecate reprmime (mime, x) repr (mime, x)
1423
1423
@deprecate mimewritable (mime, x) showable (mime, x)
1424
1424
1425
+ # PR #26284
1426
+ @deprecate (+ )(i:: Integer , index:: CartesianIndex ) (i* one (index) + index)
1427
+ @deprecate (+ )(index:: CartesianIndex , i:: Integer ) (index + i* one (index))
1428
+ @deprecate (- )(i:: Integer , index:: CartesianIndex ) (i* one (index) - index)
1429
+ @deprecate (- )(index:: CartesianIndex , i:: Integer ) (index - i* one (index))
1430
+
1425
1431
# PR #23332
1426
1432
@deprecate ^ (x, p:: Integer ) Base. power_by_squaring (x,p)
1427
1433
Original file line number Diff line number Diff line change @@ -112,10 +112,6 @@ module IteratorsMD
112
112
@inline max (index1:: CartesianIndex{N} , index2:: CartesianIndex{N} ) where {N} =
113
113
CartesianIndex {N} (map (max, index1. I, index2. I))
114
114
115
- @inline (+ )(i:: Integer , index:: CartesianIndex ) = index+ i
116
- @inline (+ )(index:: CartesianIndex{N} , i:: Integer ) where {N} = CartesianIndex {N} (map (x-> x+ i, index. I))
117
- @inline (- )(index:: CartesianIndex{N} , i:: Integer ) where {N} = CartesianIndex {N} (map (x-> x- i, index. I))
118
- @inline (- )(i:: Integer , index:: CartesianIndex{N} ) where {N} = CartesianIndex {N} (map (x-> i- x, index. I))
119
115
@inline (* )(a:: Integer , index:: CartesianIndex{N} ) where {N} = CartesianIndex {N} (map (x-> a* x, index. I))
120
116
@inline (* )(index:: CartesianIndex , a:: Integer ) = * (a,index)
121
117
@@ -279,7 +275,7 @@ module IteratorsMD
279
275
@inline function start (iter:: CartesianIndices )
280
276
iterfirst, iterlast = first (iter), last (iter)
281
277
if any (map (> , iterfirst. I, iterlast. I))
282
- return iterlast+ 1
278
+ return iterlast+ one (iterlast)
283
279
end
284
280
iterfirst
285
281
end
Original file line number Diff line number Diff line change @@ -1616,8 +1616,8 @@ end
1616
1616
@test I2 + I1 == CartesianIndex ((1 ,8 ,2 ))
1617
1617
@test I1 - I2 == CartesianIndex ((3 ,- 2 ,- 2 ))
1618
1618
@test I2 - I1 == CartesianIndex ((- 3 ,2 ,2 ))
1619
- @test I1 + 1 == CartesianIndex ((3 ,4 ,1 ))
1620
- @test I1 - 2 == CartesianIndex ((0 ,1 ,- 2 ))
1619
+ @test I1 + 1 * one (I1) == CartesianIndex ((3 ,4 ,1 ))
1620
+ @test I1 - 2 * one (I1) == CartesianIndex ((0 ,1 ,- 2 ))
1621
1621
1622
1622
@test zero (CartesianIndex{2 }) == CartesianIndex ((0 ,0 ))
1623
1623
@test zero (CartesianIndex ((2 ,3 ))) == CartesianIndex ((0 ,0 ))
You can’t perform that action at this time.
0 commit comments