-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Docs for wrapdims
say
wrapdims(table, value, names...; default=undef, sort=false, force=false)
ConstructKeyedArray(NamedDimsArray(A,names),keys)
from atable
matching
the Tables.jl API.
(It must support bothTables.columns
andTables.rows
.)
The contents of the array is taken from the columnvalue::Symbol
of the table.
Each symbol innames
specifies a column whose unique entries
become the keys along a dimenension of the array.
It works with the most basic column-table:
julia> wrapdims((a=[1, 2], b=[2, 1]), :a, :b)
1-dimensional KeyedArray(NamedDimsArray(...)) with keys:
↓ b ∈ 2-element Vector{Int64}
And data, 2-element Vector{Int64}:
(2) 1
(1) 2
but not with a rowtable - an exception gets thrown:
julia> wrapdims([(a=1, b=2), (a=2, b=1)], :a, :b)
ERROR: ArgumentError: wrong number of names, got (:a, :b) with ndims(A) == 1
Stacktrace:
[1] check_names(A::Vector{NamedTuple{(:a, :b), Tuple{Int64, Int64}}}, names::Tuple{Symbol, Symbol})
@ AxisKeys ~/.julia/packages/AxisKeys/KCixh/src/wrap.jl:105
[2] wrapdims(A::Vector{NamedTuple{(:a, :b), Tuple{Int64, Int64}}}, n::Symbol, names::Symbol)
@ AxisKeys ~/.julia/packages/AxisKeys/KCixh/src/wrap.jl:87
Looks like a wrong method gets dispatched: https://github.com/mcabbott/AxisKeys.jl/blob/master/src/wrap.jl#L87 instead of https://github.com/mcabbott/AxisKeys.jl/blob/master/src/tables.jl#L213.
Metadata
Metadata
Assignees
Labels
No labels