home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1074069600

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/6395#issuecomment-1074069600 https://api.github.com/repos/pydata/xarray/issues/6395 1074069600 IC_kwDOAMm_X85ABQBg 4160723 2022-03-21T15:51:45Z 2022-03-21T15:51:45Z MEMBER

This is expected behavior: Xarray variable objects can wrap numpy arrays but generally they don't make copies of the underlying data. So it is possible that two different variables wrap the same numpy array, like in your example and in the example below.

```python data = np.array([1, 2, 3])

v1 = xr.Variable("x", data) v2 = xr.Variable("x", data)

print(v1)

<xarray.Variable (x: 3)>

array([1, 2, 3])

print(v2)

<xarray.Variable (x: 3)>

array([1, 2, 3])

data[0] = 10

print(v1)

<xarray.Variable (x: 3)>

array([10, 2, 3])

print(v2)

<xarray.Variable (x: 3)>

array([10, 2, 3])

```

Dataset.copy(deep=True) makes a deep copy, thus copying the underlying data.

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