Skip to content

Inplace update fails with Implicit naming of numpy indexers #10387

Open
@ricardoV94

Description

@ricardoV94

What happened?

import xarray as xr

x = xr.DataArray(np.zeros((2, 3)), dims=("a", "b"))
assert x[("b", np.array([0, 1, 0])),].shape == (3,)

x[("b", np.array([0, 1, 0])),] += 1  # ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

Under the hood, this ends up being called, which fails:

x.variable[("b", np.array([0, 1, 0])),]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triageIssue that has not been reviewed by xarray team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions