Skip to content

LazilyOuterIndexedArray doesn't support slicing with slice objects #3022

@mrocklin

Description

@mrocklin

Code Sample, a copy-pastable example if possible

from xarray.core.indexing import LazilyOuterIndexedArray
import numpy as np
x = LazilyOuterIndexedArray(np.ones((5, 5)))
x[:3]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-42bee9beb30a> in <module>
----> 1 x[:3]

~/workspace/xarray/xarray/core/indexing.py in __getitem__(self, indexer)
    518             array = LazilyVectorizedIndexedArray(self.array, self.key)
    519             return array[indexer]
--> 520         return type(self)(self.array, self._updated_key(indexer))
    521
    522     def __setitem__(self, key, value):

~/workspace/xarray/xarray/core/indexing.py in _updated_key(self, new_key)
    483
    484     def _updated_key(self, new_key):
--> 485         iter_new_key = iter(expanded_indexer(new_key.tuple, self.ndim))
    486         full_key = []
    487         for size, k in zip(self.array.shape, self.key.tuple):

AttributeError: 'slice' object has no attribute 'tuple'

Problem description

Dask array meta computations like to run x[:0, :0] on input arrays. This breaks with this class.

This is on master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions