10
10
11
11
const Symbols = Tuple{Symbol,Vararg{Symbol}}
12
12
13
- @doc """
13
+ """
14
14
Type-stable axis-specific indexing and identification with a
15
15
parametric type.
16
16
@@ -47,7 +47,7 @@ A[Axis{:row}(2)] # grabs the second row
47
47
A[Axis{2}(2:5)] # grabs the second through 5th columns
48
48
```
49
49
50
- """ ->
50
+ """
51
51
immutable Axis{name,T}
52
52
val:: T
53
53
end
@@ -70,7 +70,7 @@ Base.length(A::Axis) = length(A.val)
70
70
Base. convert {name,T} (:: Type{Axis{name,T}} , ax:: Axis{name,T} ) = ax
71
71
Base. convert {name,T} (:: Type{Axis{name,T}} , ax:: Axis{name} ) = Axis {name} (convert (T, ax. val))
72
72
73
- @doc """
73
+ """
74
74
An AxisArray is an AbstractArray that wraps another AbstractArray and
75
75
adds axis names and values to each array dimension. AxisArrays can be indexed
76
76
by using the named axes as an alternative to positional indexing by
@@ -154,7 +154,7 @@ A[Axis{:time}(ClosedInterval(.2,.4))] # restrict the AxisArray along the time ax
154
154
A[ClosedInterval(0.,.3), [:a, :c]] # select an interval and two columns
155
155
```
156
156
157
- """ ->
157
+ """
158
158
immutable AxisArray{T,N,D,Ax} <: AbstractArray{T,N}
159
159
data:: D # D <:AbstractArray, enforced in constructor to avoid dispatch bugs (https://github.com/JuliaLang/julia/issues/6383)
160
160
axes:: Ax # Ax<:NTuple{N, Axis}, but with specialized Axis{...} types
@@ -229,13 +229,13 @@ HasAxes{A<:AbstractArray}(::Type{A}) = HasAxes{false}()
229
229
HasAxes (A:: AbstractArray ) = HasAxes (typeof (A))
230
230
231
231
# Axis definitions
232
- @doc """
232
+ """
233
233
axisdim(::AxisArray, ::Axis) -> Int
234
234
axisdim(::AxisArray, ::Type{Axis}) -> Int
235
235
236
236
Given an AxisArray and an Axis, return the integer dimension of
237
237
the Axis within the array.
238
- """ ->
238
+ """
239
239
axisdim (A:: AxisArray , ax:: Axis ) = axisdim (A, typeof (ax))
240
240
@generated function axisdim {T<:Axis} (A:: AxisArray , ax:: Type{T} )
241
241
dim = axisdim (A, T)
@@ -460,14 +460,14 @@ function Base.summary(A::AxisArray)
460
460
end
461
461
462
462
# Custom methods specific to AxisArrays
463
- @doc """
463
+ """
464
464
axisnames(A::AxisArray) -> (Symbol...)
465
465
axisnames(::Type{AxisArray{...}}) -> (Symbol...)
466
466
axisnames(ax::Axis...) -> (Symbol...)
467
467
axisnames(::Type{Axis{...}}...) -> (Symbol...)
468
468
469
469
Returns the axis names of an AxisArray or list of Axises as a tuple of Symbols.
470
- """ ->
470
+ """
471
471
axisnames {T,N,D,Ax} (:: AxisArray{T,N,D,Ax} ) = _axisnames (Ax)
472
472
axisnames {T,N,D,Ax} (:: Type{AxisArray{T,N,D,Ax}} ) = _axisnames (Ax)
473
473
axisnames {Ax<:Tuple{Vararg{Axis}}} (:: Type{Ax} ) = _axisnames (Ax)
@@ -481,17 +481,17 @@ axisname{name,T}(::Type{Axis{name,T}}) = name
481
481
axisname {name } (:: Type{Axis{name }} ) = name
482
482
axisname (ax:: Axis ) = axisname (typeof (ax))
483
483
484
- @doc """
484
+ """
485
485
axisvalues(A::AxisArray) -> (AbstractVector...)
486
486
axisvalues(ax::Axis...) -> (AbstractVector...)
487
487
488
488
Returns the axis values of an AxisArray or list of Axises as a tuple of vectors.
489
- """ ->
489
+ """
490
490
axisvalues (A:: AxisArray ) = axisvalues (A. axes... )
491
491
axisvalues () = ()
492
492
axisvalues (ax:: Axis , axs:: Axis... ) = tuple (ax. val, axisvalues (axs... )... )
493
493
494
- @doc """
494
+ """
495
495
axes(A::AxisArray) -> (Axis...)
496
496
axes(A::AxisArray, ax::Axis) -> Axis
497
497
axes(A::AxisArray, dim::Int) -> Axis
@@ -503,7 +503,7 @@ than `axes(A)[1]`.
503
503
504
504
For an AbstractArray without `Axis` information, `axes` returns the
505
505
default axes, i.e., those that would be produced by `AxisArray(A)`.
506
- """ ->
506
+ """
507
507
axes (A:: AxisArray ) = A. axes
508
508
axes (A:: AxisArray , dim:: Int ) = A. axes[dim]
509
509
axes (A:: AxisArray , ax:: Axis ) = axes (A, typeof (ax))
0 commit comments