Skip to content

Allow some notion of ordering in Dataset dims #8498

Closed as not planned
Closed as not planned
@max-sixty

Description

@max-sixty

What is your issue?

Currently a DataArray's dims are ordered, while a Dataset's are not.

Do we gain anything from have unordered dims in a Dataset? Could we have an ordering without enforcing it on every variable?

Here's one proposal, with fairly wide error-bars:

  • Datasets have a dim order, which is set at construction time or through .transpose
    • Currently .transpose changes the order of each variable's dims, but not the dataset's
    • If dims aren't supplied, we can just use the first variable's
  • Variables don't have to conform to that order — .assign(foo=differently_ordered) maintains the differently ordered dims. So this doesn't limit any current functionality.
  • When there are transformations which change dim ordering, Xarray is "allowed" to transpose variables to the dataset's ordering. Currently Xarray is "allowed" to change dim order arbitrarily — for example to put a core dim last. IIUC, we'd prefer to set a non-arbitrary order, but we don't have one to reference.
    • This would remove a bunch of boilerplate from methods that save the ordering, run .apply_ufunc and then reorder in the original order1

What do folks think?

Footnotes

  1. though also we could do this in .apply_ufunc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions