Skip to content

Reusing coordinate doesn't show in the dimensions #1499

Closed
@lewisacidic

Description

@lewisacidic

For a DataArray, when reusing a coordinate for multiple dimensions (is this expected usage?), it only shows once in the repr:

>>> x = xr.IndexVariable(data=range(5), dims='x')
>>> da = xr.DataArray(data=np.random.randn(5, 5), coords={'x': x}, dims=('x', 'x'))
>>> da
<xarray.DataArray (x: 5)>
array([[ 0.704139,  0.135638, -0.84717 , -0.580167,  0.95755 ],
       [ 0.966196, -0.126107,  0.547461,  1.075547, -0.477495],
       [-0.507956, -0.671571,  1.271085,  0.007741, -0.37878 ],
       [-0.969021, -0.440854,  0.062914, -0.3337  , -0.775898],
       [ 0.86893 ,  0.227861,  1.831021,  0.702769,  0.868767]])
Coordinates:
  * x        (x) int64 0 1 2 3 4

I think it should be

<xarray.DataArray (x: 5, x: 5)>
array([[ ... ]])
Coordinates:
  * x        (x) int64 0 1 2 3 4

Otherwise, everything appears to work exactly as I would expect.

This isn't an issue for Datasets:

>>> xr.Dataset({'da': da})
<xarray.Dataset>
Dimensions:  (x: 5)
Coordinates:
  * x        (x) int64 0 1 2 3 4
Data variables:
    da       (x, x) float64 0.08976 0.1049 -1.291 -0.4605 -0.005165 -0.3259 ...

Thanks!

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