DimensionalData.jl
DimensionalData.jl copied to clipboard
LookupArrays.order does not work on Dimension with Vector of String
I would have expected to get Unordered() back from that call based on the docstring.
julia> dim = Dim{:Colors}(["Red", "Blue", "Green"])
Dim{:Colors} String["Red", "Blue", "Green"]
julia> DimensionalData.Dimensions.LookupArrays.order(dim)
ERROR: MethodError: no method matching order(::Vector{String})
Closest candidates are:
order(::DimTable, Any...)
@ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/tables.jl:224
order(::Tuple{})
@ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/Dimensions/dimension.jl:229
order(::DimensionalData.Dimensions.LookupArrays.AbstractCategorical)
@ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/LookupArrays/lookup_arrays.jl:444
...
Stacktrace:
[1] order(dim::Dim{:Colors, Vector{String}})
@ DimensionalData.Dimensions ~/.julia/packages/DimensionalData/R7veM/src/Dimensions/dimension.jl:223
[2] top-level scope
@ REPL[134]:1
The dimension has to pass through a format call before any of that works, as happens in DimArray construction.
We cant do it on Dimension construction because its not always type-stable or cost-free, and Dimensions are used to wrap heaps of things besides LookupArray.
I guess we could make these functions call format ? its currently all a bit obscure how the type detection actually works...
BTW what is the use-case for this?
I cant remember. I was debugging something and got surprised by this. I think we could clarify the docstring and then close it.