Skip to content

Commit 0082a1d

Browse files
Tokazamatimholy
authored andcommitted
Addi range interface methods to Axis (#176)
1 parent ef47b4a commit 0082a1d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/core.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ Base.IteratorEltype(::Type{<:Axis}) = Base.HasEltype()
8989
Base.iterate(::Type{T}) where {T<:Axis} = (T, nothing)
9090
Base.iterate(::Type{T}, ::Any) where {T<:Axis} = nothing
9191

92+
Base.first(A::Axis) = first(A.val)
93+
Base.last(A::Axis) = last(A.val)
94+
Base.step(A::Axis{name,<:AbstractRange}) where {name} = step(A.val)
95+
9296
"""
9397
An AxisArray is an AbstractArray that wraps another AbstractArray and
9498
adds axis names and values to each array dimension. AxisArrays can be indexed

test/core.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ T = A[AxisArrays.Axis{:x}]
197197
@test length(Axis{:col}(-1:2)) === 4
198198
@test AxisArrays.axisname(Axis{:foo}(1:2)) == :foo
199199
@test AxisArrays.axisname(Axis{:foo}) == :foo
200+
@test first(Axis{:row}(1:3)) == 1
201+
@test step(Axis{:row}(1:3)) == 1
202+
@test last(Axis{:row}(1:3)) == 3
200203

201204
# Test Timetype axis construction
202205
dt, vals = DateTime(2010, 1, 2, 3, 40), randn(5,2)

0 commit comments

Comments
 (0)