home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1773296009

This data as json

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
1773296009 I_kwDOAMm_X85pslmJ 7940 decide on how to handle `empty_like` 90008 open 0     8 2023-06-25T13:48:46Z 2023-07-05T16:36:35Z   CONTRIBUTOR      

Is your feature request related to a problem?

calling np.empty_like seems to be instantiating the whole array.

```python from xarray.tests import InaccessibleArray import xarray as xr import numpy as np

array = InaccessibleArray(np.zeros((3, 3), dtype="uint8")) da = xr.DataArray(array, dims=["x", "y"])

np.empty_like(da) ```

python Traceback (most recent call last): File "/home/mark/t.py", line 8, in <module> np.empty_like(da) File "/home/mark/mambaforge/envs/dev/lib/python3.9/site-packages/xarray/core/common.py", line 165, in __array__ return np.asarray(self.values, dtype=dtype) File "/home/mark/mambaforge/envs/dev/lib/python3.9/site-packages/xarray/core/dataarray.py", line 732, in values return self.variable.values File "/home/mark/mambaforge/envs/dev/lib/python3.9/site-packages/xarray/core/variable.py", line 614, in values return _as_array_or_item(self._data) File "/home/mark/mambaforge/envs/dev/lib/python3.9/site-packages/xarray/core/variable.py", line 314, in _as_array_or_item data = np.asarray(data) File "/home/mark/mambaforge/envs/dev/lib/python3.9/site-packages/xarray/tests/__init__.py", line 151, in __array__ raise UnexpectedDataAccess("Tried accessing data") xarray.tests.UnexpectedDataAccess: Tried accessing data

Describe the solution you'd like

I'm not too sure. This is why I raised this as a "feature" and not a bug.

On one hand, it is pretty hard to "get" the underlying class.

Is it a:

  • numpy array
  • a lazy thing that looks like a numpy array?
  • a dask array when it is dask?

I think that there are also some nuances between:

  1. Loading an nc file from a file (where things might be handled by dask even though you don't want them to be)
  2. Creating your xarray from in memory.

Describe alternatives you've considered

for now, i'm trying to avoid empty_like or zeros_like.

In general, we haven't seen much benefit from dask and cuda still needs careful memory management.

Additional context

No response

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7940/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 0.744ms · About: xarray-datasette