Skip to content

Silent bug when indexing with boolean scalars #10379

Open
@ricardoV94

Description

@ricardoV94

I think this is an edge case that should fail, it does if we use a 0d xarray as indexer, but not if using a numpy array or a python bool:

import xarray as xr

x = xr.DataArray(np.arange(9).reshape((3, 3)), dims=("a", "b"))
x[np.array(True)]
# <xarray.DataArray (b: 3)> Size: 24B
# array([3, 4, 5])
# Dimensions without coordinates: b

Seems to be treating it simply as an integer

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