home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

3 rows where issue = 1175517164 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 2

  • benbovy 2
  • zoj613 1

author_association 2

  • MEMBER 2
  • NONE 1

issue 1

  • two Dataset objects reference the same numpy array memory block upon creation. · 3 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1075081836 https://github.com/pydata/xarray/issues/6395#issuecomment-1075081836 https://api.github.com/repos/pydata/xarray/issues/6395 IC_kwDOAMm_X85AFHJs benbovy 4160723 2022-03-22T11:52:31Z 2022-03-22T11:52:31Z MEMBER

Maybe this could be mentioned as a note in the docstring somewhere?

Yes that's a good idea. There's a brief mention in the docs here: https://docs.xarray.dev/en/stable/user-guide/data-structures.html#dictionary-like-methods, but I agree we could make it clearer.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  two Dataset objects reference the same numpy array memory block upon creation. 1175517164
1074074385 https://github.com/pydata/xarray/issues/6395#issuecomment-1074074385 https://api.github.com/repos/pydata/xarray/issues/6395 IC_kwDOAMm_X85ABRMR zoj613 44142765 2022-03-21T15:56:27Z 2022-03-21T15:56:27Z NONE

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.

Thanks for the quick response. I wasn't aware of this. I had assumed a new Dataset object will have data that is a copy of the underlying var_map data pass into it. Maybe this could be mentioned as a note in the docstring somewhere?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  two Dataset objects reference the same numpy array memory block upon creation. 1175517164
1074069600 https://github.com/pydata/xarray/issues/6395#issuecomment-1074069600 https://api.github.com/repos/pydata/xarray/issues/6395 IC_kwDOAMm_X85ABQBg benbovy 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
}
  two Dataset objects reference the same numpy array memory block upon creation. 1175517164

Advanced export

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

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 14.7ms · About: xarray-datasette