home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

8 rows where author_association = "MEMBER" and issue = 623751213 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 3

  • mathause 3
  • keewis 3
  • max-sixty 2

issue 1

  • xr.cov() and xr.corr() · 8 ✖

author_association 1

  • MEMBER · 8 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
633922774 https://github.com/pydata/xarray/pull/4089#issuecomment-633922774 https://api.github.com/repos/pydata/xarray/issues/4089 MDEyOklzc3VlQ29tbWVudDYzMzkyMjc3NA== keewis 14808389 2020-05-26T09:43:29Z 2020-05-26T09:43:29Z MEMBER

thanks. Do you want to put in a PR fixing that?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xr.cov() and xr.corr() 623751213
633651803 https://github.com/pydata/xarray/pull/4089#issuecomment-633651803 https://api.github.com/repos/pydata/xarray/issues/4089 MDEyOklzc3VlQ29tbWVudDYzMzY1MTgwMw== max-sixty 5635139 2020-05-25T16:55:26Z 2020-05-25T16:55:26Z MEMBER

Awesome @AndrewWilliams3142 ! Very excited we have this.

Thanks for the review @mathause

Hitting merge; any other feedback is welcome and we can iterate.

{
    "total_count": 3,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 2,
    "rocket": 1,
    "eyes": 0
}
  xr.cov() and xr.corr() 623751213
633590099 https://github.com/pydata/xarray/pull/4089#issuecomment-633590099 https://api.github.com/repos/pydata/xarray/issues/4089 MDEyOklzc3VlQ29tbWVudDYzMzU5MDA5OQ== mathause 10194086 2020-05-25T14:08:35Z 2020-05-25T14:08:35Z MEMBER

If you insist ;)

da_a -= da_a.mean(dim=dim) is indeed marginally faster. As they are already aligned, we don't have to worry about this.

{
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 1,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xr.cov() and xr.corr() 623751213
633449839 https://github.com/pydata/xarray/pull/4089#issuecomment-633449839 https://api.github.com/repos/pydata/xarray/issues/4089 MDEyOklzc3VlQ29tbWVudDYzMzQ0OTgzOQ== mathause 10194086 2020-05-25T08:29:22Z 2020-05-25T08:29:22Z MEMBER

Could you also add a test for the TypeError?

python with raises_regex(TypeError, "Only xr.DataArray is supported"): xr.corr(xr.Dataset(), xr.Dataset())

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xr.cov() and xr.corr() 623751213
633393615 https://github.com/pydata/xarray/pull/4089#issuecomment-633393615 https://api.github.com/repos/pydata/xarray/issues/4089 MDEyOklzc3VlQ29tbWVudDYzMzM5MzYxNQ== max-sixty 5635139 2020-05-25T06:03:24Z 2020-05-25T06:03:24Z MEMBER

This looks great! I think it's fine to have a simple implementation like this, even if it's not perfectly efficient. Well done for getting something working @AndrewWilliams3142 .

For the future: let's move away from using np.random in docstrings, since they're not reproducible, and will never pass a doctest.

Anything remaining before merging?

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xr.cov() and xr.corr() 623751213
633310925 https://github.com/pydata/xarray/pull/4089#issuecomment-633310925 https://api.github.com/repos/pydata/xarray/issues/4089 MDEyOklzc3VlQ29tbWVudDYzMzMxMDkyNQ== keewis 14808389 2020-05-24T22:38:54Z 2020-05-24T22:38:54Z MEMBER

no worries about hypothesis, that's something we can add in a new PR.

Also, I don't think there is a hypothesis.extra.xarray module, yet. Any comments on that, @Zac-HD?

{
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 1,
    "rocket": 0,
    "eyes": 0
}
  xr.cov() and xr.corr() 623751213
633299554 https://github.com/pydata/xarray/pull/4089#issuecomment-633299554 https://api.github.com/repos/pydata/xarray/issues/4089 MDEyOklzc3VlQ29tbWVudDYzMzI5OTU1NA== mathause 10194086 2020-05-24T21:04:03Z 2020-05-24T21:04:03Z MEMBER

Currently corr needs to sanitize the inputs twice, which will be inefficient. One way around this is to define an internal method which can do both, depending on a method keyword (no need to write extra tests for this IMHO):

```python

def corr(da_a, da_b, dim=None, ddof=0):

    return _cov_corr(da_a, da_b, dim=None, ddof=0, method="corr")

def cov(da_a, da_b, dim=None, ddof=0):

return _cov_corr(da_a, da_b, dim=None, ddof=0, method="cov")

def _cov_corr(da_a, da_b, dim=None, ddof=0, method=None):

# compute cov

if method = "cov":
    return cov

# compute corr

return corr

```

Maybe you could use xr.apply_ufunc instead of looping in the tests (might be overkill).

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xr.cov() and xr.corr() 623751213
633216248 https://github.com/pydata/xarray/pull/4089#issuecomment-633216248 https://api.github.com/repos/pydata/xarray/issues/4089 MDEyOklzc3VlQ29tbWVudDYzMzIxNjI0OA== keewis 14808389 2020-05-24T11:22:42Z 2020-05-24T12:09:51Z MEMBER

If you want to test individual values without reimplementing the function in the tests (which is what I suspect comparing with the result of np.cov would require), that might be the only way.

If not, you could also check properties of covariance / correlation matrices, e.g. that assert_allclose(xr.cov(a, b) / (a.std() * b.std()), xr.corr(a, b)) (I'm not sure if I remember that formula correctly) or that the diagonal of the auto-covariance matrix is the same as the variance of the array (with a 1D vector, not sure about more dimensions). If you decide to test using properties, you could also extend our small collection of tests using hypothesis (see #1846).

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xr.cov() and xr.corr() 623751213

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