home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

7 rows where issue = 573031381 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 5

  • max-sixty 3
  • djhoese 1
  • dcherian 1
  • bradyrx 1
  • rbavery 1

author_association 3

  • MEMBER 4
  • CONTRIBUTOR 2
  • NONE 1

issue 1

  • Xarray operations produce read-only array · 7 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
592799268 https://github.com/pydata/xarray/issues/3813#issuecomment-592799268 https://api.github.com/repos/pydata/xarray/issues/3813 MDEyOklzc3VlQ29tbWVudDU5Mjc5OTI2OA== dcherian 2448579 2020-02-29T01:06:05Z 2023-03-22T15:11:09Z MEMBER

It's usually expand_dims.

We should add an FAQ for little things like this.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray operations produce read-only array 573031381
809858535 https://github.com/pydata/xarray/issues/3813#issuecomment-809858535 https://api.github.com/repos/pydata/xarray/issues/3813 MDEyOklzc3VlQ29tbWVudDgwOTg1ODUzNQ== rbavery 22258697 2021-03-30T02:31:54Z 2021-03-30T02:31:54Z NONE

I ran into the same issue as @bradyrx with writable arrays and apply_ufunc. An addition to the docs FAQ or apply_ufunc docs would help clarify that you can't write to the array inputs in the ufunc. I also want to +1 @bradyrx 's idea of making an arg to apply_ufunc that copies the input arrays to handle this common use case.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray operations produce read-only array 573031381
655142333 https://github.com/pydata/xarray/issues/3813#issuecomment-655142333 https://api.github.com/repos/pydata/xarray/issues/3813 MDEyOklzc3VlQ29tbWVudDY1NTE0MjMzMw== bradyrx 8881170 2020-07-07T21:22:30Z 2020-07-07T21:22:30Z CONTRIBUTOR

FYI, this is also seen on xr.apply_ufunc, but only when vectorize=True. It seems like ndarrays write switch are turned off when vectorize=True. This is also solved by .copy(), which is good anways to avoid mutating the original ndarrays. Perhaps also a copy=bool could be added to apply_ufunc to create copies of the ndarrays? I'd be happy to lead that PR if it makes sense.

Example:

``python def match_nans(a, b): """Pairwise matching of nans between two time series.""" # Try with and without.copy` commands. # a = a.copy() # b = b.copy() if np.isnan(a).any() or np.isnan(b).any(): idx = np.logical_or(np.isnan(a), np.isnan(b)) a[idx], b[idx] = np.nan, np.nan return a, b

A = xr.DataArray(np.random.rand(10, 5), dims=['time', 'space']) B = xr.DataArray(np.random.rand(10, 5), dims=['time', 'space']) A[0, 1] = np.nan B[5, 0] = np.nan

xr.apply_ufunc(match_nans, A, B, input_core_dims=[['time'], ['time']], output_core_dims=[['time'], ['time']], # Try with and without vectorize. vectorize=True,) ```

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray operations produce read-only array 573031381
592874409 https://github.com/pydata/xarray/issues/3813#issuecomment-592874409 https://api.github.com/repos/pydata/xarray/issues/3813 MDEyOklzc3VlQ29tbWVudDU5Mjg3NDQwOQ== max-sixty 5635139 2020-02-29T04:56:45Z 2020-02-29T04:56:45Z MEMBER

Cheers @djhoese

Yes, let's leave this open. Two follow-ups from https://github.com/pydata/xarray/issues/2891#issuecomment-482880911; we would welcome PRs:

  • Mention the work-around of using .copy() in the error message xarray prints when an array is read-only.

  • Add a copy argument to expand_dims, so users can write copy=True if they want a writeable result.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray operations produce read-only array 573031381
592847155 https://github.com/pydata/xarray/issues/3813#issuecomment-592847155 https://api.github.com/repos/pydata/xarray/issues/3813 MDEyOklzc3VlQ29tbWVudDU5Mjg0NzE1NQ== djhoese 1828519 2020-02-29T03:38:46Z 2020-02-29T03:38:46Z CONTRIBUTOR

@max-sixty That's exactly it. What's really weird for this is that the original code in Satpy is using a dask array and not a numpy array. It seemed very strange to both copy the DataArray (.copy()), convert the dask array to a numpy array (np.asarray), and then still get a read-only array.

I can understand how xarray would treat numpy arrays and dask arrays the same when it comes to this, but coming from outside the project it is very surprising that a dask array would be marked as read-only when it was used to just create a "new" numpy array.

Feel free to close this or use it as a marker to clarify some documentation or error messages as mentioned in #2891.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray operations produce read-only array 573031381
592805831 https://github.com/pydata/xarray/issues/3813#issuecomment-592805831 https://api.github.com/repos/pydata/xarray/issues/3813 MDEyOklzc3VlQ29tbWVudDU5MjgwNTgzMQ== max-sixty 5635139 2020-02-29T01:35:54Z 2020-02-29T01:35:54Z MEMBER

https://github.com/pydata/xarray/issues/2891

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray operations produce read-only array 573031381
592760687 https://github.com/pydata/xarray/issues/3813#issuecomment-592760687 https://api.github.com/repos/pydata/xarray/issues/3813 MDEyOklzc3VlQ29tbWVudDU5Mjc2MDY4Nw== max-sixty 5635139 2020-02-28T22:35:18Z 2020-02-28T22:35:18Z MEMBER

Thanks for the report @djhoese . Confirmed in 0.15.0 too.

Do you know which of those steps causes the array to become non-writeable?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray operations produce read-only array 573031381

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