home / github

Menu
  • Search all tables
  • GraphQL API

issues

Table actions
  • GraphQL API for issues

1 row where state = "open" and user = 25624127 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date)

type 1

  • issue 1

state 1

  • open · 1 ✖

repo 1

  • xarray 1
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
1060646604 I_kwDOAMm_X84_OC7M 6015 TypeError: '_ElementwiseFunctionArray' object does not support item assignment tomvothecoder 25624127 open 0     0 2021-11-22T22:19:24Z 2021-11-22T23:38:17Z   CONTRIBUTOR      

What happened: I am attempting to mask specific time_bnds coordinate points using loc, but am receiving TypeError: '_ElementwiseFunctionArray' object does not support item assignment.

This happens when calling ds = xr.open_dataset("path/to/file", decode_times=False), followed by ds = xr.decode_cf(ds, decode_times=True).

What you expected to happen:

The time_bnds coordinate points selected using .loc should mask.

Minimal Complete Verifiable Example:

```python import numpy as np import xarray as xr

file_path = "./input/ts_Amon_ACCESS1-0_historical_r1i1p1_185001-200512.nc"

This works fine

ds = xr.open_dataset(file_path, decode_times=True) ds["time_bnds"].loc[dict(time="1850-01")] = np.nan

This breaks

ds2 = xr.open_dataset(file_path, decode_times=False) ds2 = xr.decode_cf(ds2, decode_times=True) ds2["time_bnds"].loc[dict(time="1850-01")] = np.nan


TypeError Traceback (most recent call last) ~/Documents/Repositories/XCDAT/xcdat/qa/PR47 temporal avg/bugs/qa_seasonal_bug.py in <module> 13 ds2 = xr.open_dataset(file_path, decode_times=False) 14 ds2 = xr.decode_cf(ds2, decode_times=True) ----> 15 ds2["time_bnds"].loc[dict(time="1850-01")] = np.nan

/opt/miniconda3/envs/xcdat_dev/lib/python3.9/site-packages/xarray/core/dataarray.py in setitem(self, key, value) 212 213 pos_indexers, _ = remap_label_indexers(self.data_array, key) --> 214 self.data_array[pos_indexers] = value 215 216

/opt/miniconda3/envs/xcdat_dev/lib/python3.9/site-packages/xarray/core/dataarray.py in setitem(self, key, value) 765 for k, v in self._item_key_to_dict(key).items() 766 } --> 767 self.variable[key] = value 768 769 def delitem(self, key: Any) -> None:

/opt/miniconda3/envs/xcdat_dev/lib/python3.9/site-packages/xarray/core/variable.py in setitem(self, key, value) 852 853 indexable = as_indexable(self._data) --> 854 indexable[index_tuple] = value 855 856 @property

/opt/miniconda3/envs/xcdat_dev/lib/python3.9/site-packages/xarray/core/indexing.py in setitem(self, key, value) 435 ) 436 full_key = self._updated_key(key) --> 437 self.array[full_key] = value 438 439 def repr(self):

TypeError: '_ElementwiseFunctionArray' object does not support item assignment

```

Anything else we need to know?:

The workaround is to perform .load() after xr.decode_cf() ```python

This works

ds3 = xr.open_dataset(file_path, decode_times=False) ds3 = xr.decode_cf(ds3, decode_times=True) ds3.load() ds3["time_bnds"].loc[dict(time="1850-01")] = np.nan ```

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 20:33:18) [Clang 11.1.0 ] python-bits: 64 OS: Darwin OS-release: 19.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: (None, 'UTF-8') libhdf5: 1.12.1 libnetcdf: 4.8.1 xarray: 0.19.0 pandas: 1.3.3 numpy: 1.21.2 scipy: None netCDF4: 1.5.7 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.5.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2021.09.1 distributed: 2021.09.1 matplotlib: None cartopy: None seaborn: None numbagg: None pint: None setuptools: 58.2.0 pip: 21.2.4 conda: None pytest: 6.2.5 IPython: 7.28.0 sphinx: 4.2.0
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6015/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 issue

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issues] (
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [number] INTEGER,
   [title] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [state] TEXT,
   [locked] INTEGER,
   [assignee] INTEGER REFERENCES [users]([id]),
   [milestone] INTEGER REFERENCES [milestones]([id]),
   [comments] INTEGER,
   [created_at] TEXT,
   [updated_at] TEXT,
   [closed_at] TEXT,
   [author_association] TEXT,
   [active_lock_reason] TEXT,
   [draft] INTEGER,
   [pull_request] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [state_reason] TEXT,
   [repo] INTEGER REFERENCES [repos]([id]),
   [type] TEXT
);
CREATE INDEX [idx_issues_repo]
    ON [issues] ([repo]);
CREATE INDEX [idx_issues_milestone]
    ON [issues] ([milestone]);
CREATE INDEX [idx_issues_assignee]
    ON [issues] ([assignee]);
CREATE INDEX [idx_issues_user]
    ON [issues] ([user]);
Powered by Datasette · Queries took 798.584ms · About: xarray-datasette