Skip to content

Commit 0c3d0f6

Browse files
authored
Propagate iteration to parent in OffsetArrays (#257)
* propagate iteration to parent * Fix tests
1 parent a598424 commit 0c3d0f6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/OffsetArrays.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ end
441441
A
442442
end
443443

444+
@inline Base.iterate(a::OffsetArray, i...) = iterate(parent(a), i...)
445+
444446
Base.in(x, A::OffsetArray) = in(x, parent(A))
445447
Base.copy(A::OffsetArray) = parent_call(copy, A)
446448

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,12 @@ end
14921492
@test a == d
14931493
end
14941494
end
1495+
1496+
v = ones(10)
1497+
for r in Any[1:1:10, 1:10], s in Any[r, collect(r)]
1498+
so = OffsetArray(s)
1499+
@test Float64[v[i] for i in s] == Float64[v[i] for i in so]
1500+
end
14951501
end
14961502

14971503
@testset "show/summary" begin

0 commit comments

Comments
 (0)