Skip to content

Instantly share code, notes, and snippets.

View jaimefrio's full-sized avatar

Jaime jaimefrio

  • Google
  • Zurich, Switzerland
View GitHub Profile
@seberg
seberg / stride_tricks.py
Created August 22, 2012 22:39
numy stride tricks based functions for changing the shape and axis order of arrays.
import numpy as np
from collections import defaultdict as _dd
def rolling_window(array, window=(0,), asteps=None, wsteps=None, axes=None, toend=True):
"""Create a view of `array` which for every point gives the n-dimensional
neighbourhood of size window. New dimensions are added at the end of
`array` or after the corresponding original dimension.
Parameters
----------