Skip to content

AxisArrays.axisnames should instead extend Base.names? #155

Open
@nickrobinson251

Description

@nickrobinson251

I had expected names to work i.e.

julia> using AxisArrays

julia> A = AxisArray(reshape(1:15, 5, 3), Axis{:time}(.1:.1:0.5), Axis{:col}([:a, :b, :c]))
5×3 AxisArray{Int64,2,Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Tuple{Axis{:time,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Axis{:col,Array{Symbol,1}}}}:
 1   6  11
 2   7  12
 3   8  13
 4   9  14
 5  10  15

julia> names(A)
# (:time, :col)

julia> names(A.axes)
# (:time, :col)

julia> names(A.axes[1])
# :time

but these all give MethodErrors -- I instead need to use AxisArrays.axisnames(A) and AxisArrays.axisname(A.axes[1]) (and there is no AxisArrays.axisnames(A.axes)).

The precedent for extending Base.names comes from DataFrames.jl e.g.

julia> using DataFrames

julia> df = DataFrame(a = 1:5, b = 6:10)
5×2 DataFrame
│ Row │ a     │ b     │
│     │ Int64 │ Int64 │
├─────┼───────┼───────┤
│ 116     │
│ 227     │
│ 338     │
│ 449     │
│ 5510    │

julia> names(df)
2-element Array{Symbol,1}:
 :a
 :b

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions