Skip to content

Request a warning for when coord names are ignored when dims are specified #11234

@sol-et-stellae

Description

@sol-et-stellae

What is your issue?

When coords are specified in tuple format, their names are silently ignored when dims names are also specified.

The following expression yields a DataArray that retains no reference to the otherwise specified coords of a, b, and c, in favor of the positionally-associated names of dims, x, y, and z.

DataArray(
    data=[[[1]], [[2]], [[3]]],
    dims=["x", "y", "z"],
    coords=[("a", [5, 6, 7]), ("b", [8]), ("c", [9])]
)

The result is:

<xarray.DataArray (x: 3, y: 1, z: 1)> Size: 24B
array([[[1]],
       [[2]],
       [[3]]])
Coordinates:
  * x        (x) int64 24B 5 6 7
  * y        (y) int64 8B 8
  * z        (z) int64 8B 9

Even though this behavior is documented, I think the user should be warned that the coordinate names do not match the dimension names and have been overridden.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions