html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/pull/6874#issuecomment-1484205746,https://api.github.com/repos/pydata/xarray/issues/6874,1484205746,IC_kwDOAMm_X85Ydy6y,2448579,2023-03-26T19:58:05Z,2023-03-26T19:58:05Z,MEMBER,"I'd like to merge this at the end of next week.
It now has tests and should be backwards compatible with external backends.
A good next step would be to finish up #7020 ","{""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 1, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1327380960
https://github.com/pydata/xarray/pull/6874#issuecomment-1433777395,https://api.github.com/repos/pydata/xarray/issues/6874,1433777395,IC_kwDOAMm_X85VdbTz,2448579,2023-02-16T22:03:22Z,2023-02-16T22:03:22Z,MEMBER,`T_ExplicitlyIndexed` may be a different thing to add,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1327380960
https://github.com/pydata/xarray/pull/6874#issuecomment-1433681353,https://api.github.com/repos/pydata/xarray/issues/6874,1433681353,IC_kwDOAMm_X85VdD3J,14371165,2023-02-16T20:34:16Z,2023-02-16T20:34:16Z,MEMBER,"I don't have a better idea than to do `DuckArray = Any # ndarray/cupy/sparse etc.` and add that as output, but that wont change anything mypy-wise besides making it easier for us to read the code.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1327380960
https://github.com/pydata/xarray/pull/6874#issuecomment-1433629099,https://api.github.com/repos/pydata/xarray/issues/6874,1433629099,IC_kwDOAMm_X85Vc3Gr,2448579,2023-02-16T19:52:38Z,2023-02-16T19:52:38Z,MEMBER,@Illviljan feel free to push any typing changes to this PR. I think that would really help clarify the interface. I tried adding a `DuckArray` type but that didn't go to far.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1327380960
https://github.com/pydata/xarray/pull/6874#issuecomment-1385842347,https://api.github.com/repos/pydata/xarray/issues/6874,1385842347,IC_kwDOAMm_X85Smkar,2448579,2023-01-17T18:21:01Z,2023-01-17T18:26:51Z,MEMBER,"### background
(Moving the convo out of a [comment](https://github.com/pydata/xarray/pull/6874#discussion_r946154605) for visibility)
For reference, the code we would like is
``` python
array = as_indexable(self.array)
array = array[self.key]
array = array.get_duck_array()
```
### problem
So far I have found two fail cases
#### 1. Wrapping a backend array instance
> This method is removing LazilyIndexedArray. When we do that, we sometimes have another ExplicitlyIndexed array (_ElementwiseFunctionArray) and sometimes a BackendArray. We then apply array[self.key] which returns a ExplicitlyIndexed array for the former and forces a load from disk for the latter.
> One way to solve this would be to return another ExplicitlyIndexed array from the __getitem__ on the BackendArrays. This is currently forcing a load from disk:
I tried this by making `__getitem__` on a `BackendArrayWrapper` return a `ExplicitlyIndexed` array ([commit](https://github.com/pydata/xarray/pull/6874/commits/9b727e6e716beb04e4702b35d8ecfe7b896280ec)). This breaks all existing backends, and is a little complicated to add to the Zarr and Scipy backends.
#### 2. Wrapping an IndexingAdapter instance
The other case is when `as_indexable` returns an `IndexingAdapter` instance. Again, these return duck arrays from `__getitem__`, so we can't call `get_duck_array`
https://github.com/pydata/xarray/blob/522ee2210499cfa434a0ca0825790949a8e08ff0/xarray/core/indexing.py#L671-L690
### how to proceed?
@shoyer I'm not sure on how to proceed.
1. For BackendArrays we could wrap them in another lazy indexing class when the Variable is created so we don't break our backend entrypoint contract (that `__getitem__` can return a duck array). We might need something like this for TensorStore anyway.
2. I don't know what to do about the indexing adapters.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1327380960
https://github.com/pydata/xarray/pull/6874#issuecomment-1204280307,https://api.github.com/repos/pydata/xarray/issues/6874,1204280307,IC_kwDOAMm_X85Hx9vz,1217238,2022-08-03T17:44:20Z,2022-08-03T17:44:20Z,MEMBER,"As I understand it, the main purpose here is to remove Xarray lazy indexing class.
Maybe call this `get_duck_array()`, just to be a little more descriptive?","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1327380960