Skip to content

Should Categorical lookups be ordered by default? #1133

@tiemvanderdeure

Description

@tiemvanderdeure

Categorical dimensions are assigned ForwardOrdered or ReverseOrdered if they are ordered, e.g.:

julia> da = rand(Dim{:var}(["temperature", "soil_moisture", "precipitation"]))
┌ 3-element DimArray{Float64, 1} ┐
├────────────────────────────────┴───────────────────────────────────────── dims ┐
  ↓ var Categorical{String} ["temperature", …, "precipitation"] ReverseOrdered
└────────────────────────────────────────────────────────────────────────────────┘
 "temperature"    0.148941
 "soil_moisture"  0.915144
 "precipitation"  0.576853

With #847 this might cause errors when indexing with a vector.

I would propose all Categorical lookups should be Unordered by default - there are very few cases where strings or symbols are really ordered (for Char you could argue otherwise though). There are many cases where a dimensions just isn't very big so the chance of it randomly being either ForwardOrdered or ReverseOrdered is quite big, and for dimensions of length 2 even 100%.

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