home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 1258538050

This data as json

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/issues/2835#issuecomment-1258538050 https://api.github.com/repos/pydata/xarray/issues/2835 1258538050 IC_kwDOAMm_X85LA8RC 4447466 2022-09-26T19:48:39Z 2022-09-26T19:52:14Z CONTRIBUTOR

OK, new test now pushed as #7086. (Hopefully added in the right place and style!)

A couple of additional notes:

  • Revision to my comment above: this actually fails in 2022.3 and 2022.6 for nested attribs.
  • I took a look at the source code in dataarray.py, but couldn't see an obvious way to fix this and/or didn't understand the attrs copying process generally.
  • I tested the equivalent case for DataSet attrs too (see below), and this seems fine as per your previous comments above, so I think https://github.com/pydata/xarray/pull/2839 (which includes a ds level test) still applies to ds.attrs, however the issue does affect the individual arrays within the dataset still (as expected).

```python import xarray as xr

ds = xr.Dataset({"a": (["x"], [1, 2, 3])}, attrs={"t": 1, "nested":{"t2": 1}}) ds.a.attrs = {"t": 'a1', "nested":{"t2": 'a1'}}

ds2 = ds.copy(deep=True) ds.attrs["t"] = 5 ds.attrs["nested"]["t2"] = 10

ds2.a.attrs["t"] = 'a2' ds2.a.attrs["nested"]["t2"] = 'a2'

print(ds.attrs) print(ds.a.attrs) print(ds2.attrs) print(ds2.a.attrs)

```

Results in:

``` {'t': 5, 'nested': {'t2': 10}} {'t': 'a1', 'nested': {'t2': 'a2'}} {'t': 1, 'nested': {'t2': 1}} {'t': 'a2', 'nested': {'t2': 'a2'}}

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  423742774
Powered by Datasette · Queries took 159.68ms · About: xarray-datasette