Skip to content

Commit 703c19b

Browse files
committed
Fix indices for OffsetArrays
1 parent 35e9b1f commit 703c19b

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "2.14.9"
3+
version = "2.14.10"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/ranges.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ specified, then the indices for visiting each index of `x` are returned.
441441
return inds
442442
end
443443
end
444+
@inline indices(x::AbstractUnitRange{<:Integer}) = Base.Slice(OptionallyStaticUnitRange(x))
444445

445446
function indices(x::Tuple)
446447
inds = map(eachindex, x)

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ using OffsetArrays
358358
B = Array{Int8}(undef, 2,2,2,2);
359359
doubleperm = PermutedDimsArray(PermutedDimsArray(B,(4,2,3,1)), (4,2,1,3));
360360
@test collect(strides(B))[collect(stride_rank(doubleperm))] == collect(strides(doubleperm))
361+
362+
@test @inferred(ArrayInterface.indices(OffsetArray(view(PermutedDimsArray(A, (3,1,2)), 1, :, 2:4)', 3, -173),1)) === Base.Slice(ArrayInterface.OptionallyStaticUnitRange(4,6))
363+
@test @inferred(ArrayInterface.indices(OffsetArray(view(PermutedDimsArray(A, (3,1,2)), 1, :, 2:4)', 3, -173),2)) === Base.Slice(ArrayInterface.OptionallyStaticUnitRange(-172,-170))
361364
end
362365

363366
@testset "Static-Dynamic Size, Strides, and Offsets" begin

0 commit comments

Comments
 (0)