mcabbott / mcabbott/AxisKeys.jl
Tables.jl `wrapdims` doesn't work on `StructArray`
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 154
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
It works on DataFrame but not StructArray.
using AxisKeys, DataFrames, StructArrays
julia> wrapdims(DataFrame(a=[1,1,2,2], b=[:x, :y, :x, :y], c=[10, 20, 30, 40]), :c, :a, :b)
2-dimensional KeyedArray(NamedDimsArray(...)) with keys:
↓ a ∈ 2-element Vector{Int64}
→ b ∈ 2-element Vector{Symbol}
And data, 2×2 Matrix{Int64}:
(:x) (:y)
(1) 10 20
(2) 30 40
julia> wrapdims(StructArray(a=[1,1,2,2], b=[:x, :y, :x, :y], c=[10, 20, 30, 40]), :c, :a, :b)
ERROR: ArgumentError: wrong number of names, got (:c, :a, :b) with ndims(A) == 1
Stacktrace:
[1] check_names(A::StructVector{@NamedTuple{…}, @NamedTuple{…}, Int64}, names::Tuple{Symbol, Symbol, Symbol})
@ AxisKeys ~/.julia/packages/AxisKeys/sYP4R/src/wrap.jl:103
[2] wrapdims(::StructVector{@NamedTuple{…}, @NamedTuple{…}, Int64}, ::Symbol, ::Symbol, ::Symbol)
@ AxisKeys ~/.julia/packages/AxisKeys/sYP4R/src/wrap.jl:85
[3] top-level scope
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Julia reproduction in the issue and inspect AxisKeys/src/wrap.jl, especially the wrapdims and check_names paths shown in the stack trace. Compare the StructArray input with the working DataFrame case, then verify that wrapdims accepts the three names and produces the same two-dimensional keyed result for StructArray.
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
- Clearly specified
- Newbie friendliness
- 45/100