Skip to content

Use numpy & dask sliding_window_view for rolling #4977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Mar 26, 2021

Conversation

dcherian
Copy link
Contributor

@dcherian dcherian commented Mar 1, 2021

@dcherian dcherian marked this pull request as draft March 1, 2021 15:54
@@ -29,38 +29,3 @@ def test_vindex():
vindex[[0, 1], [0, 1], :] = vindex[[0, 1], [0, 1], :]
vindex[[0, 1], :, [0, 1]] = vindex[[0, 1], :, [0, 1]]
vindex[:, [0, 1], [0, 1]] = vindex[:, [0, 1], [0, 1]]


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to test_variable

@dcherian
Copy link
Contributor Author

dcherian commented Mar 1, 2021

sliding_window_view dispatches with array_function so we could support other duck array libraries if they implemented it. cc @keewis

Copy link
Collaborator

@keewis keewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do a thorough review, but I have a few comments.

sliding_window_view dispatches with array_function

yes, this is really great.

dcherian added 3 commits March 5, 2021 07:07
…indow

* upstream/master:
  add polyval to polyfit see also (pydata#5020)
  mention map_blocks in the docstring of apply_ufunc (pydata#5011)
  Switch backend API to v2 (pydata#4989)
  WIP: add new backend api documentation (pydata#4810)
  pin netCDF4=1.5.3 in min-all-deps (pydata#4982)
  fix matplotlib errors for single level discrete colormaps (pydata#4256)
  Adapt exception handling in CFTimeIndex.__sub__ and __rsub__ (pydata#5006)
  Update options.py (pydata#5000)
  Adjust tests to use updated pandas syntax for offsets (pydata#4537)
  add a combine_attrs parameter to Dataset.merge (pydata#4895)
  Support for dask.graph_manipulation (pydata#4965)
  raise on passing axis to Dataset.reduce methods (pydata#4940)
Copy link
Collaborator

@mathause mathause left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I am still interested to eventually fix #2007. This PR may also make that easier as it now uses Variable.pad.

@dcherian
Copy link
Contributor Author

dcherian commented Mar 13, 2021

I am still interested to eventually fix #2007. This PR may also make that easier as it now uses Variable.pad.

That's the goal i.e. make it easier to fix #2007 and minimize number of code paths for rolling. This PR reduces the number of places we call pad from 4 to 3 :P. The two bottleneck code paths still do their own padding.

Co-authored-by: Mathias Hauser <[email protected]>
@dcherian dcherian marked this pull request as ready for review March 18, 2021 16:29
…indow

* upstream/master:
  Fix regression in decoding large standard calendar times (pydata#5050)
  Fix sticky sidebar responsiveness on small screens (pydata#5039)
  Flexible indexes refactoring notes (pydata#4979)
  add a install xarray step to the upstream-dev CI (pydata#5044)
  Adds Dataset.query() method, analogous to pandas DataFrame.query() (pydata#4984)
  run tests on python 3.9 (pydata#5040)
  Add date attribute to datetime accessor (pydata#4994)
  📚 New theme & rearrangement of the docs (pydata#4835)
  upgrade ci-trigger to the most recent version (pydata#5037)
  GH5005 fix documentation on open_rasterio (pydata#5021)
  GHA for automatically canceling previous CI runs (pydata#5025)
  Implement GroupBy.__getitem__ (pydata#3691)
  conventions: decode unsigned integers to signed if _Unsigned=false (pydata#4966)
  Added support for numpy.bool_ (pydata#4986)
  Add additional str accessor methods for DataArray (pydata#4622)
…nto rolling-sliding-window

* 'rolling-sliding-window' of github.com:dcherian/xarray:
  Update xarray/core/npcompat.py
  Apply suggestions from code review
@dcherian
Copy link
Contributor Author

The dask PR was merged so this should be ready to go.

@mathause
Copy link
Collaborator

mathause commented Mar 18, 2021

It looked pretty good when I reviewed it, so 👍

Just quickly skimming the code it did not become entirely clear to me why this had to be after dask/dask#7234? You don't import sliding_window_view from dask. Also you re-define sliding_window_view in dask_array_compat.py - why don't you need this in dask proper? (Not complaining just wondering. Also feel free to not answer the question if you don't have time.)

@dcherian
Copy link
Contributor Author

You don't import sliding_window_view from dask.

haha. fixed!

I was waiting on that PR to see if the reviews would catch any bugs.

@andersy005
Copy link
Member

@dcherian, should we test this in upstream-dev CI workflow (via the [test-upstream] keyword)?

@dcherian dcherian force-pushed the rolling-sliding-window branch from d7c37a7 to 39f9e28 Compare March 18, 2021 17:10
@dcherian
Copy link
Contributor Author

thanks @andersy005 !

@dcherian dcherian merged commit fdf024c into pydata:master Mar 26, 2021
@dcherian dcherian deleted the rolling-sliding-window branch March 26, 2021 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants