Skip to content

Unexpected dimension values after sum #1159

@thirtysixbananas

Description

@thirtysixbananas

Not sure how important this is. I hit this scenario, but at least I can extract the numbers I need.

How are dimension values named after aggregation?
Here's a nice example:

A = rand(X(1.0:0.2:2.0), Y([:a, :b, :c]))
sum(A; dims=2)

┌ 6×1 DimArray{Float64, 2} ┐
├──────────────────────────┴───────────────────────────────── dims ┐
  ↓ X Sampled{Float64} 1.0:0.2:2.0 ForwardOrdered Regular Points,
  → Y Categorical{Symbol} [:combined] ForwardOrdered
└──────────────────────────────────────────────────────────────────┘
 ↓ →   :combined
 1.0  2.38466
 1.2  1.65471
 1.4  1.2786
 1.6  0.525329
 1.8  1.11983
 2.0  0.838832

The Y now has only one value which is :combined. Ok nice.

Here's an example where it's less nice:

@enumx MyThing Thing1 Thing2
A = rand(X(1.0:0.2:2.0), Y([(MyThing.Thing1, "rah"), (MyThing.Thing2, "lala"), (MyThing.Thing1, "hmm")]))
sum(A; dims=2)

┌ 6×1 DimArray{Float64, 2} ┐
├──────────────────────────┴──────────────────────────────────────────────────────────────────────────── dims ┐
  ↓ X Sampled{Float64} 1.0:0.2:2.0 ForwardOrdered Regular Points,
  → Y Sampled{Tuple{Main.MyThing.T, String}} [(Main.MyThing.Thing2, "lala")] ForwardOrdered Irregular Points
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
 ↓ →   (Thing2, "lala")
 1.0  1.22294
 1.2  1.76796
 1.4  1.25219
 1.6  2.16251
 1.8  0.974786
 2.0  1.41384

The Y now takes an arbitrary value of one of the pre-aggregation values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions