JuliaArrays / JuliaArrays/AxisArrays.jl

Indexing order is not preserved when indexing by name

Open
#213 3 comments 1 reaction 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

This seems pretty bad to me and I don't think it's documented. I'd like to call it a bug and fix it in minor release if that is acceptable.

julia> x = AxisArray([1,2], [:a, :b])
1-dimensional AxisArray{Int64,1,...} with axes:
    :row, [:a, :b]
And data, a 2-element Vector{Int64}:
 1
 2

julia> x[[:a, :b]] # Okay
1-dimensional AxisArray{Int64,1,...} with axes:
    :row, [:a, :b]
And data, a 2-element Vector{Int64}:
 1
 2

julia> x[[:b, :a]] # Should flip, but doesn't
1-dimensional AxisArray{Int64,1,...} with axes:
    :row, [:a, :b]
And data, a 2-element Vector{Int64}:
 1
 2

julia> x[[2, 1]] # Should flip and does
1-dimensional AxisArray{Int64,1,...} with axes:
    :row, [:b, :a]
And data, a 2-element Vector{Int64}:
 2
 1

Possibly related to #204

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

Reproduce the Julia examples from the issue, then inspect the indexing-by-name implementation and the discussion in issue #204. The fix is complete when x[[:b, :a]] returns data [2, 1] with axes [:b, :a], matching positional indexing, with a regression test for the demonstrated case.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.