home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 633145887

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/3784#issuecomment-633145887 https://api.github.com/repos/pydata/xarray/issues/3784 633145887 MDEyOklzc3VlQ29tbWVudDYzMzE0NTg4Nw== 56925856 2020-05-23T21:58:49Z 2020-05-23T21:58:49Z CONTRIBUTOR

In a fit of covid-induced insanity, I've decided to have a crack at finishing up #3550 ! I'm playing around with the changes made by @r-beer at the moment, but I'm finding the tests quite confusing - I think they're wrong? But maybe someone could help me out with this?

Here's something from test_computation.py in #3550 ```python def test_cov(da_a, da_b, dim): def pandas_cov(ts1, ts2): """Ensure the ts are aligned and missing values ignored""" ts1, ts2 = xr.align(ts1, ts2) valid_values = ts1.notnull() & ts2.notnull()

    ts1 = ts1.where(valid_values, drop=True)
    ts2 = ts2.where(valid_values, drop=True)

    return ts1.to_series().cov(ts2.to_series())

expected = pandas_cov(da_a, da_b)
actual = xr.cov(da_a, da_b, dim)

assert_allclose(actual, expected)

```

What I don't understand is, why would we expect the Pandas covariance or correlation functions to return anything remotely like the output of xr.cov()? The line ts1.to_series().cov(ts2.to_series()) always produces a scalar value, whereas in most reasonable use cases xr.cov(da_a, da_b, dim) would be producing a matrix of values (eg. the pixel-wise correlation in time between two DataArrays).

I wasn't sure whether to open a PR for this or not? I'm working on it but would require some help to set up some appropriate tests...

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  568378007
Powered by Datasette · Queries took 79.788ms · About: xarray-datasette