Skip to content

DataArray coords: tuple vs. list #1016

Closed
@jonathanstrong

Description

@jonathanstrong

is there a reason the coords dictionary values cannot be a tuple? I found this fairly baffling to debug when it tripped me up.

# this works
xarray.DataArray(np.random.random((3, 3, 3)),
    dims=('one', 'two', 'three'),
    coords={
         'one': ['four', 'five', 'six'],
    }
)

# this throws the following error
# ValueError: dimensions ('four',) must have the same length as the number of data dimensions, ndim=0
xarray.DataArray(np.random.random((3, 3, 3)),
    dims=('one', 'two', 'three'),
    coords={
         'one': ('four', 'five', 'six'),
    }
)

even if there was a clearer error it would help quite a bit. As it stands you are thinking, 'what?! four isn't a dimension!'

using 0.8.2

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