Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/OffsetArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ Broadcast.broadcast_unalias(dest::OffsetArray, src::OffsetArray) = parent(dest)
const OffsetRange{T} = OffsetVector{T,<:AbstractRange{T}}
const OffsetUnitRange{T} = OffsetVector{T,<:AbstractUnitRange{T}}

Base.step(a::OffsetRange) = step(parent(a))
for f in [:first, :last, :step]
@eval Base.$f(a::OffsetRange) = $f(parent(a))
end

Base.checkindex(::Type{Bool}, inds::AbstractUnitRange, or::OffsetRange) = Base.checkindex(Bool, inds, parent(or))

Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,14 @@ end
@test a == d
end
end

# Special methods for an OffsetRange
for r in Any[3:10, 3:1:10, UnitRange(3.0, 10.0), 3.0:1.0:10.0]
ro = OffsetArray(r)
@test first(ro) == first(r)
@test last(ro) == last(r)
@test step(ro) == step(r)
end
end

@testset "show/summary" begin
Expand Down