Skip to content

Commit

Permalink
Merge c9ad669 into 76a3a3d
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Sep 11, 2016
2 parents 76a3a3d + c9ad669 commit f533c6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Base.unsafe_getindex(A::Axis, i...) = Base.unsafe_getindex(A, i...)
Base.eltype{_,T}(::Type{Axis{_,T}}) = eltype(T)
Base.size(A::Axis) = size(A.val)
Base.length(A::Axis) = length(A.val)
@compat (A::Axis{name}){name}(i) = Axis{name}(i)

@doc """
An AxisArray is an AbstractArray that wraps another AbstractArray and
Expand Down
2 changes: 2 additions & 0 deletions test/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ B = AxisArray(reshape(1:15, 5,3), .1:.1:0.5, [:a, :b, :c])
@test B[Axis{:row}(Interval(0.15, 0.3))] == B[2:3,:]

A = AxisArray(reshape(1:256, 4,4,4,4), Axis{:d1}(.1:.1:.4), Axis{:d2}(1//10:1//10:4//10), Axis{:d3}(["1","2","3","4"]), Axis{:d4}([:a, :b, :c, :d]))
ax1 = axes(A)[1]
@test A[Axis{:d1}(2)] == A[ax1(2)]
@test A.data[1:2,:,:,:] == A[Axis{:d1}(Interval(.1,.2))] == A[Interval(.1,.2),:,:,:] == A[Interval(.1,.2),:,:,:,1] == A[Interval(.1,.2)]
@test A.data[:,1:2,:,:] == A[Axis{:d2}(Interval(1//10,2//10))] == A[:,Interval(1//10,2//10),:,:] == A[:,Interval(1//10,2//10),:,:,1] == A[:,Interval(1//10,2//10)]
@test A.data[:,:,1:2,:] == A[Axis{:d3}(["1","2"])] == A[:,:,["1","2"],:] == A[:,:,["1","2"],:,1] == A[:,:,["1","2"]]
Expand Down

0 comments on commit f533c6e

Please sign in to comment.