Skip to content

ds.coords.dims can display dims not present in the coordinate vars #9466

Description

@TomNicholas

This (on main) looks wrong to me:

In [1]: import xarray as xr

In [2]: ds = xr.Dataset({'a': ('x', [0, 1])})

In [3]: ds
Out[3]: 
<xarray.Dataset> Size: 16B
Dimensions:  (x: 2)
Dimensions without coordinates: x
Data variables:
    a        (x) int64 16B 0 1

In [4]: ds.coords
Out[4]: 
Coordinates:
    *empty*

In [5]: ds.coords.dims
Out[5]: FrozenMappingWarningOnValuesAccess({'x': 2})

I mean the fact no-one has raised this before means it probably isn't of much consequence, but it does seem incorrect / misleading.

Originally posted by @TomNicholas in #9451 (comment)

The issue here being that the DatasetCoordinates object displays a dim with no associated variable.

I'm not sure whether anything about the concept of "virtual coordinate variables" affects this.

(The FrozenMappingWarningOnValuesAccess is just a Mapping, it's only weird due to the ongoing deprecation cycle started in #8500.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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