home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

2 rows where issue = 59308959 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 2

  • shoyer 1
  • earlew 1

author_association 2

  • MEMBER 1
  • NONE 1

issue 1

  • DataArrays initialized with the same data behave like views of each other · 2 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
76500617 https://github.com/pydata/xarray/issues/343#issuecomment-76500617 https://api.github.com/repos/pydata/xarray/issues/343 MDEyOklzc3VlQ29tbWVudDc2NTAwNjE3 earlew 7462311 2015-02-28T01:02:27Z 2015-02-28T01:02:27Z NONE

Points taken. Thanks for responding so quickly. I didn't realize that Pandas does something similar. I understand that the default behavior of NumPy/Python is to pass by reference (assignment) but I didn't realize that this rule applies even when converting an object from one type to another. Now that I have checked, np.ma.masked_array also uses a reference to the input data by default (however, it also provides the option for creating a copy).

In the API reference for DataArray, it probably wouldn't hurt to say that the input data is not copied by default and that a reference is used instead. I guess making note of this would only benefit less experienced users like myself, but it would be appreciated.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArrays initialized with the same data behave like views of each other 59308959
76493025 https://github.com/pydata/xarray/issues/343#issuecomment-76493025 https://api.github.com/repos/pydata/xarray/issues/343 MDEyOklzc3VlQ29tbWVudDc2NDkzMDI1 shoyer 1217238 2015-02-27T23:36:02Z 2015-02-27T23:36:02Z MEMBER

Just for reference, pandas does the same thing here:

``` In [8]: import numpy as np

In [9]: x = np.zeros((4,4))

In [10]: df1 = pd.DataFrame(x)

In [11]: df2 = pd.DataFrame(x)

In [12]: df1.loc[:] = 1

In [13]: df1 Out[13]: 0 1 2 3 0 1 1 1 1 1 1 1 1 1 2 1 1 1 1 3 1 1 1 1

In [14]: df2 Out[14]: 0 1 2 3 0 1 1 1 1 1 1 1 1 1 2 1 1 1 1 3 1 1 1 1 ```

I think this is more of a NumPy gotcha than an xray gotcha, per se.

From my perspective as an experienced NumPy user, this makes sense -- array data is not copied unless explicitly requested. Passing by reference instead of by value (like in MATLAB or R) is pretty fundamental to NumPy/Python, and it makes it many operations much more efficient.

The alternative here is indeed making our own defensive copy. I don't like that option because it will slow everything down, and xray will no longer meet the expectations of expert Python users. Unfortunately, NumPy does not have any sort of support for copy on write.

But, if you have suggestions for how to clarify this in xray's documentation, that would be greatly appreciated!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArrays initialized with the same data behave like views of each other 59308959

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 482.307ms · About: xarray-datasette