home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

3 rows where issue = 1370063272 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

  • p4perf4ce 2
  • mathause 1

author_association 2

  • CONTRIBUTOR 2
  • MEMBER 1

issue 1

  • Inconsistent behavior between `DatasetRolling.construct` and `DataArrayRolling.construct` with stride > 1. · 3 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1452521051 https://github.com/pydata/xarray/issues/7021#issuecomment-1452521051 https://api.github.com/repos/pydata/xarray/issues/7021 IC_kwDOAMm_X85Wk7Zb p4perf4ce 39671216 2023-03-02T20:47:11Z 2023-03-02T20:47:11Z CONTRIBUTOR

Been half a year and I found myself stuck at this inconsistent behavior again. Another problem I found but haven't mentioned yet is that DatasetRolling.construct will swap the rolling dimension name with window_dim when DataArrayRolling.construct doesn't.

This time, I've actually identified a cause for this problem below:

https://github.com/pydata/xarray/blob/b018442c8dfa3e71ec35e294de69e2011949afec/xarray/core/rolling.py#L789-L791

python .isel({d: slice(None, None, s) for d, s in zip(self.dim, strides)})

I currently still can't figure it out what is the original intention that .isel trying to achieve since it causes so much problem without any benefit. It should be noted that this can explode the memory if xr.Dataset is reasonably large (It just explode 3 channels PPG, 135Hz, 6Hrs of recording, a mere 300MB to 20-40GB++, so I think this is critical).

Solution

Removing .isel part fixed everything.

Test case

python test_arr = xr.DataArray(np.arange(8).reshape(2, 4), dims=('a', 'b')) # Borrowed from `DataArray.__doc__`'s example. test_dset= xr.Dataset(data_vars={i: tr for i in range(3)}) DataArray ```python tr.rolling(b=2).construct('window_dim', stride=2)

<xarray.DataArray (a: 2, b: 2, window_dim: 2)> array([[[nan, 0.], [ 1., 2.]],

   [[nan,  4.],
    [ 5.,  6.]]])

Dimensions without coordinates: a, b, window_dim Datasetpython trd.rolling(b=2).construct('window_dim', stride=2)

<xarray.Dataset> Dimensions: (a: 2, b: 2, window_dim: 2) Dimensions without coordinates: a, b, window_dim Data variables: 0 (a, b, window_dim) float64 nan 0.0 1.0 2.0 nan 4.0 5.0 6.0 1 (a, b, window_dim) float64 nan 0.0 1.0 2.0 nan 4.0 5.0 6.0 2 (a, b, window_dim) float64 nan 0.0 1.0 2.0 nan 4.0 5.0 6.0

trd.rolling(b=2).construct('window_dim', stride=2)[0]

<xarray.DataArray 0 (a: 2, b: 2, window_dim: 2)> array([[[nan, 0.], [ 1., 2.]],

   [[nan,  4.],
    [ 5.,  6.]]])

Dimensions without coordinates: a, b, window_dim ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Inconsistent behavior between `DatasetRolling.construct` and `DataArrayRolling.construct` with stride > 1. 1370063272
1244634332 https://github.com/pydata/xarray/issues/7021#issuecomment-1244634332 https://api.github.com/repos/pydata/xarray/issues/7021 IC_kwDOAMm_X85KL5zc p4perf4ce 39671216 2022-09-12T22:39:35Z 2022-09-12T22:42:11Z CONTRIBUTOR

Thanks for the report & I agree that this should lead to the same but the code paths are indeed different - but I have not looked in to the actual root cause. Could be that this is also not super thoroughly tested (and used!):

https://github.com/pydata/xarray/blob/b018442c8dfa3e71ec35e294de69e2011949afec/xarray/core/rolling.py#L289

https://github.com/pydata/xarray/blob/b018442c8dfa3e71ec35e294de69e2011949afec/xarray/core/rolling.py#L721

B.t.w. a copy-pastable example would be appreciated.

Thanks for the response, here is a straightforward example.

python import xarray as xr dummy = list(range(100)) x, y, z = [xr.DataArray(dummy, dims=['t']) for _ in range(3)] ds = xr.Dataset( {'x': x, 'y': y, 'z': z} ) print(x.rolling(t=4).construct('w', stride=4).shape) print(ds.rolling(t=4).construct('w', stride=4).x.shape) Results: ```

(25, 4) (7, 4) ```

I had a hunch that the problem come from this part - not quite sure what self._mapping_to_list did here, haven't look it up yet. https://github.com/pydata/xarray/blob/b018442c8dfa3e71ec35e294de69e2011949afec/xarray/core/rolling.py#L764-L772

Since I only had one dimension to deal with, removing this loop solves the problem for me.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Inconsistent behavior between `DatasetRolling.construct` and `DataArrayRolling.construct` with stride > 1. 1370063272
1244602741 https://github.com/pydata/xarray/issues/7021#issuecomment-1244602741 https://api.github.com/repos/pydata/xarray/issues/7021 IC_kwDOAMm_X85KLyF1 mathause 10194086 2022-09-12T22:23:27Z 2022-09-12T22:23:27Z MEMBER

Thanks for the report & I agree that this should lead to the same but the code paths are indeed different - but I have not looked in to the actual root cause. Could be that this is also not super thoroughly tested (and used!):

https://github.com/pydata/xarray/blob/b018442c8dfa3e71ec35e294de69e2011949afec/xarray/core/rolling.py#L289

https://github.com/pydata/xarray/blob/b018442c8dfa3e71ec35e294de69e2011949afec/xarray/core/rolling.py#L721

B.t.w. a copy-pastable example would be appreciated.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Inconsistent behavior between `DatasetRolling.construct` and `DataArrayRolling.construct` with stride > 1. 1370063272

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