id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 1327380960,PR_kwDOAMm_X848lec7,6874,Avoid calling np.asarray on lazy indexing classes,2448579,closed,0,,,6,2022-08-03T15:13:00Z,2023-03-31T15:15:31Z,2023-03-31T15:15:29Z,MEMBER,,0,pydata/xarray/pulls/6874,"This is motivated by https://docs.rapids.ai/api/kvikio/stable/api.html#kvikio.zarr.GDSStore which on read loads the data directly into GPU memory. Currently we rely on `np.asarray` to convert a BackendArray wrapped with a number of lazy indexing classes to a real array but this breaks for `GDSStore` because the underlying array is a cupy array, so using `np.asarray` raises an error. `np.asarray` will raise if a non-numpy array is returned so we need to use something else. Here I added `get_array` which like `np.array` recurses down until it receives a duck array. Quite a few things are broken I think , but I'd like feedback on the approach. I considered `np.asanyarray(..., like=...)` but that would require the lazy indexing classes to know what they're wrapping which doesn't seem right. Ref: https://github.com/xarray-contrib/cupy-xarray/pull/10 which adds a `kvikio` backend entrypoint ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6874/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull