Skip to content

Commit

Permalink
Merge pull request #17 from JuliaImages/teh/timeaxis
Browse files Browse the repository at this point in the history
Define a fallback for timeaxis
  • Loading branch information
timholy authored Mar 25, 2017
2 parents ff917a1 + 769acf9 commit 718cc71
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ImageAxes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ new names as well.
Return the time axis, if present, of the array `A`, and `nothing` otherwise.
"""
@inline timeaxis(A::AxisArray) = _timeaxis(A.axes...)
timeaxis(A::AbstractArray) = nothing
timeaxis(A::AbstractMappedArray) = timeaxis(parent(A))
@traitfn _timeaxis{Ax<:Axis; !TimeAxis{Ax}}(ax::Ax, axes...) = _timeaxis(axes...)
@traitfn _timeaxis{Ax<:Axis; TimeAxis{Ax}}(ax::Ax, axes...) = ax
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ using SimpleTraits, Unitful
@test @inferred(indices_spatial(A)) === (Base.OneTo(3), Base.OneTo(4))
assert_timedim_last(A)
@test map(istimeaxis, axes(A)) == (false,false)

@test @inferred(timeaxis(rand(3,5))) == nothing
end

@testset "units, no time" begin
Expand Down

0 comments on commit 718cc71

Please sign in to comment.