JuliaArrays / AxisArrays.jl

Performant arrays where each dimension can have a named axis with values
http://JuliaArrays.github.io/AxisArrays.jl/latest/
Other
200 stars 42 forks source link

axistrait works fine #68

Closed GordStephen closed 7 years ago

GordStephen commented 7 years ago

On both 0.5 and 0.6:

julia> using AxisArrays

julia> AxisArrays.axistrait(Axis{:myaxis}([1,2,3]))
AxisArrays.Unsupported

julia> AxisArrays.axistrait(Axis{:myaxis}([:A, :B]))
AxisArrays.Unsupported

Right now the methods are:

axistrait(::Any) = Unsupported
axistrait{T<:Union{Number, Dates.AbstractTime}}(::AbstractVector{T}) = Dimensional
axistrait{T<:Union{Symbol, AbstractString}}(::AbstractVector{T}) = Categorical

A working dispatch-based solution should be possible in 0.6, not sure about 0.5? Alternatively this could be switched over to a single method using eltype?

GordStephen commented 7 years ago

Revisiting this and looking at the type signature in the code I copy/pasted, it's painfully obvious that axistrait works perfectly fine, just not how I was erroneously thinking it did... The problem is my incorrect use of it (via checkaxis) in the cat function.

That being said, it doesn't seem unreasonable for functions named checkaxis and axistrait to accept Axis arguments... I'll submit a PR.