@@ -78,7 +78,7 @@ symbols for column headers.
7878A = AxisArray(reshape(1:15, 5,3), (.1:.1:0.5, [:a, :b, :c]), (:time, :col))
7979A[Axis{:time}(1:3)] # equivalent to A[1:3,:]
8080A[Axis{:time}(Interval(.2,.4))] # restrict the AxisArray along the time axis
81- A[Interval(0.,.3), [:a, :c]] # select an interval and two columns
81+ A[Interval(0.,.3), [:a, :c]] # select an interval and two columns
8282```
8383
8484""" ->
@@ -151,7 +151,7 @@ Base.isempty(ax::Axis) = isempty(ax.I)
151151 axisdim(::AxisArray, ::Axis) -> Int
152152 axisdim(::AxisArray, ::Type{Axis}) -> Int
153153
154- Given an AxisArray and an Axis, return the integer dimension of
154+ Given an AxisArray and an Axis, return the integer dimension of
155155the Axis within the array.
156156""" ->
157157axisdim (A:: AxisArray , ax:: Axis ) = axisdim (A, typeof (ax))
@@ -182,10 +182,23 @@ Returns the axis names of an AxisArray or AxisArray Type as a tuple of symbols.
182182""" ->
183183axisnames (A:: AxisArray ) = axisnames (typeof (A))
184184axisnames {T,N,D,names,Ax} (:: Type{AxisArray{T,N,D,names,Ax}} ) = names
185- axisnames {T,N,D,names,Ax} (:: Type{AxisArray{T,N,D,names,Ax}} ) = names
186185axisnames {T,N,D,names} (:: Type{AxisArray{T,N,D,names}} ) = names
186+
187+ @doc """
188+ axes(A::AxisArray) -> (AbstractVector...)
189+ axes(A::AxisArray, ax::Axis) -> AbstractVector
190+
191+ Returns the tuple of axis vectors for an AxisArray. If an specific `Axis` is
192+ specified, then only that axis vector is returned. Note that when extracting a
193+ single axis vector, `axes(A, Axis{1})`) is type-stable and will perform better
194+ than `axes(A)[1]`.
195+ """ ->
187196axes (A:: AxisArray ) = A. axes
188- axes (A:: AxisArray ,i:: Int ) = A. axes[i]
197+ axes (A:: AxisArray , ax:: Axis ) = axes (A, typeof (ax))
198+ stagedfunction axes {T<:Axis} (A:: AxisArray , ax:: Type{T} )
199+ dim = axisdim (A, T)
200+ :(A. axes[$ dim])
201+ end
189202
190203# ## Axis traits ###
191204abstract AxisType
0 commit comments