JuliaArrays / JuliaArrays/AxisArrays.jl

AxisArrays.axisnames should instead extend Base.names?

Open
#155 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
207
Forks
41
PR merge metrics
No merged PRs in 30d

Description

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 │
├─────┼───────┼───────┤
│ 1   │ 1     │ 6     │
│ 2   │ 2     │ 7     │
│ 3   │ 3     │ 8     │
│ 4   │ 4     │ 9     │
│ 5   │ 5     │ 10    │

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting AxisArrays.axisnames, AxisArrays.axisname, and the existing names methods for AxisArray and its axes. Reproduce the examples in the issue, then verify that names(A), names(A.axes), and names(A.axes[1]) work as shown while preserving the existing AxisArrays helpers.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.