Skip to content

Commit 8016641

Browse files
committed
Moved endof method to core.jl and added test
1 parent d1b4098 commit 8016641

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

src/core.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ axistype{name,T}(::Type{Axis{name,T}}) = T
6262
Base.getindex(A::Axis, i...) = A.val[i...]
6363
Base.eltype{_,T}(::Type{Axis{_,T}}) = eltype(T)
6464
Base.size(A::Axis) = size(A.val)
65+
Base.endof(A::Axis) = length(A)
6566
Base.indices(A::Axis) = indices(A.val)
6667
Base.indices(A::Axis, d) = indices(A.val, d)
6768
Base.length(A::Axis) = length(A.val)

src/indexing.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ using Base: ViewIndex
88
# Simple scalar indexing where we just set or return scalars
99
@inline Base.getindex(A::AxisArray, idxs::Int...) = A.data[idxs...]
1010
@inline Base.setindex!(A::AxisArray, v, idxs::Int...) = (A.data[idxs...] = v)
11-
@inline Base.endof(A::Axis) = length(A)
1211

1312
# Cartesian iteration
1413
Base.eachindex(A::AxisArray) = eachindex(A.data)

test/core.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ Aplain = rand(2,3)
165165
@test Axis{:row}(2:7)[4] == 5
166166
@test eltype(Axis{:row}(1.0:1.0:3.0)) == Float64
167167
@test size(Axis{:row}(2:7)) === (6,)
168+
T = A[AxisArrays.Axis{:x}]
169+
@test T[end] == 0.2
168170
@test indices(Axis{:row}(2:7)) === (Base.OneTo(6),)
169171
@test indices(Axis{:row}(-1:1), 1) === Base.OneTo(3)
170172
@test length(Axis{:col}(-1:2)) === 4

0 commit comments

Comments
 (0)