JuliaDataCubes / JuliaDataCubes/YAXArrays.jl

yaxconvert alters the dim names

Open
#362 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
132
Forks
25
PR merge metrics
No merged PRs in 30d

Description

why the change from D1, D2 here to Dim{:D1}, Dim{:D2} when converting a dimarray to a yaxarray?

julia> using DimensionalData, YAXArrays, YAXArrayBase

julia> DimensionalData.@dim D1

julia> DimensionalData.@dim D2

julia> dd = rand(D1(["a","b"]), D2(["x","y"]), metadata = Dict{String, Any}())
2×2 DimArray{Float64,2} with dimensions: 
  D1 Categorical{String} String["a", "b"] ForwardOrdered,
  D2 Categorical{String} String["x", "y"] ForwardOrdered
        "x"       "y"
  "a"  0.790863  0.345696
  "b"  0.490964  0.814311

julia> ddyax = yaxconvert(YAXArray, dd)
2×2 YAXArray{Float64,2} with dimensions: 
  Dim{:D1} Categorical{String} String["a", "b"] ForwardOrdered,
  Dim{:D2} Categorical{String} String["x", "y"] ForwardOrdered
Total size: 32.0 bytes

same thing happens in the other direction, yax to dd:

julia> yax = YAXArray((D1(["a","b"]), D2(["x","y"])), rand(2,2))
2×2 YAXArray{Float64,2} with dimensions: 
  D1 Categorical{String} String["a", "b"] ForwardOrdered,
  D2 Categorical{String} String["x", "y"] ForwardOrdered
Total size: 32.0 bytes


julia> yaxdd = yaxconvert(DimArray, yax)
2×2 DimArray{Float64,2} with dimensions: 
  Dim{:D1} Categorical{String} String["a", "b"] ForwardOrdered,
  Dim{:D2} Categorical{String} String["x", "y"] ForwardOrdered
        "x"       "y"
  "a"  0.27363   0.455353
  "b"  0.446381  0.709265

there is a workaround, but why doesn't yaxconvert operate like this?

julia> hack = DimArray(yax.data, dims(yax))
2×2 DimArray{Float64,2} with dimensions: 
  D1 Categorical{String} String["a", "b"] ForwardOrdered,
  D2 Categorical{String} String["x", "y"] ForwardOrdered
        "x"       "y"
  "a"  0.27363   0.455353
  "b"  0.446381  0.709265

i ask because indexing with D1 is more succinct and easier to read and type than Dim{:D1}.

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 with the yaxconvert(YAXArray, dd) and yaxconvert(DimArray, yax) entry points shown in the examples, then compare their dimension handling with the DimArray(yax.data, dims(yax)) workaround. Done means conversions preserve the D1 and D2 dimension names instead of displaying Dim{:D1} and Dim{:D2}.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.