Skip to content

Commit 3bdb4d4

Browse files
authored
fixes #261 (#262)
* fixes #261 * removed docstring
1 parent aa21e43 commit 3bdb4d4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/OffsetArrays.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ See also [`center`](@ref OffsetArrays.center).
764764
"""
765765
centered(A::AbstractArray, cp::Dims=center(A)) = OffsetArray(A, .-cp)
766766

767+
centered(A::AbstractArray, i::CartesianIndex) = centered(A, Tuple(i))
767768

768769
####
769770
# work around for segfault in searchsorted*

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,6 +2537,13 @@ end
25372537
@test parent(Aoo) === A # there will be only one OffsetArray wrapper
25382538
@test Aoo.offsets == (-2, -2)
25392539
@test Aoo[0, 0] == 5
2540+
2541+
A = reshape(collect(1:9), 3, 3)
2542+
Aoo = OffsetArrays.centered(A, CartesianIndex(2,2))
2543+
c = (0,0)
2544+
i = CartesianIndex(c...)
2545+
@test Aoo[i] == Aoo[c...]
2546+
25402547
end
25412548
end
25422549

0 commit comments

Comments
 (0)