home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

7 rows where issue = 589632313 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 3

  • max-sixty 3
  • mancellin 3
  • dcherian 1

author_association 2

  • MEMBER 4
  • CONTRIBUTOR 3

issue 1

  • In-place addition of arrays with the same coords but in a different order · 7 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
614146417 https://github.com/pydata/xarray/issues/3910#issuecomment-614146417 https://api.github.com/repos/pydata/xarray/issues/3910 MDEyOklzc3VlQ29tbWVudDYxNDE0NjQxNw== mancellin 31126826 2020-04-15T16:35:46Z 2020-04-15T16:35:46Z CONTRIBUTOR

Well actually, I would be at least as surprised if A += B returned a different result than A = A + B.

So now I understand why this is not supported. I'll submit the PR soon.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  In-place addition of arrays with the same coords but in a different order 589632313
606135881 https://github.com/pydata/xarray/issues/3910#issuecomment-606135881 https://api.github.com/repos/pydata/xarray/issues/3910 MDEyOklzc3VlQ29tbWVudDYwNjEzNTg4MQ== max-sixty 5635139 2020-03-30T17:29:36Z 2020-03-30T17:29:36Z MEMBER

Yes exactly! And I think in-place might be surprising if it changed the indexes of the left item; i.e. if you got this result from A += B:

```python

In [17]: ...: ...: import numpy as np ...: import xarray as xr ...: ...: n = 5 ...: ...: d1 = np.arange(1, n+1) ...: np.random.shuffle(d1) ...: A = xr.DataArray(np.ones(n), coords=[('dim', d1)]) ...: ...: d2 = np.arange(n) ...: np.random.shuffle(d2) ...: B = xr.DataArray(np.ones(n), coords=[('dim', d2)]) ...: ...: A + B Out[17]: <xarray.DataArray (dim: 4)> array([2., 2., 2., 2.]) Coordinates: * dim (dim) int64 3 2 1 4 ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  In-place addition of arrays with the same coords but in a different order 589632313
606100412 https://github.com/pydata/xarray/issues/3910#issuecomment-606100412 https://api.github.com/repos/pydata/xarray/issues/3910 MDEyOklzc3VlQ29tbWVudDYwNjEwMDQxMg== mancellin 31126826 2020-03-30T16:22:04Z 2020-03-30T16:22:04Z CONTRIBUTOR

Yes. But the not-in-place addition A+B works fine without conversion to float because it uses basically xr.align(A, B, join='inner'). If the in-place addition did the same, there would be no risk of type conversion. But I guess the in-place version would rather use something like xr.align(A, B, join='left') to guarantee that the shape and index of A does not change. Am I right?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  In-place addition of arrays with the same coords but in a different order 589632313
606070776 https://github.com/pydata/xarray/issues/3910#issuecomment-606070776 https://api.github.com/repos/pydata/xarray/issues/3910 MDEyOklzc3VlQ29tbWVudDYwNjA3MDc3Ng== max-sixty 5635139 2020-03-30T15:30:26Z 2020-03-30T15:30:26Z MEMBER

Thanks in advance @mancellin

Your comment is almost exactly right. It's that they might not align fully, rather than the shape; i.e. if your example had range(1,5) rather than range(0,4), then the array would need to be converted to float to add a NaN. Does that make sense?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  In-place addition of arrays with the same coords but in a different order 589632313
605847162 https://github.com/pydata/xarray/issues/3910#issuecomment-605847162 https://api.github.com/repos/pydata/xarray/issues/3910 MDEyOklzc3VlQ29tbWVudDYwNTg0NzE2Mg== mancellin 31126826 2020-03-30T08:06:32Z 2020-03-30T08:06:32Z CONTRIBUTOR

I can submit a PR. But the comment cited above is not totally clear to me.

The purpose of the conversion to floats is to have NaNs in case the shapes do not match. So the core of the issue is that A + B might not have the same shape as A, and thus in general A + B cannot replace A in-place. Is that right?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  In-place addition of arrays with the same coords but in a different order 589632313
605676519 https://github.com/pydata/xarray/issues/3910#issuecomment-605676519 https://api.github.com/repos/pydata/xarray/issues/3910 MDEyOklzc3VlQ29tbWVudDYwNTY3NjUxOQ== dcherian 2448579 2020-03-29T18:08:22Z 2020-03-29T18:08:22Z MEMBER

@mancellin Are you up for sending in a PR with a better error message?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  In-place addition of arrays with the same coords but in a different order 589632313
605501583 https://github.com/pydata/xarray/issues/3910#issuecomment-605501583 https://api.github.com/repos/pydata/xarray/issues/3910 MDEyOklzc3VlQ29tbWVudDYwNTUwMTU4Mw== max-sixty 5635139 2020-03-28T18:38:01Z 2020-03-28T18:41:52Z MEMBER

Yes, this is unfortunate. The reasoning: https://github.com/pydata/xarray/blob/732b6cd6248ce715da74f3cd7a0e211eaa1d0aa2/xarray/core/dataarray.py#L2618-L2621

It may be possible to at align in some cases (e.g. if the indexes are bijective / one-to-one, or the values are already floats). Or a better error message; even one containing that comment would be better.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  In-place addition of arrays with the same coords but in a different order 589632313

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