Skip to content

Instantly share code, notes, and snippets.

@stephtdouglas
Last active March 26, 2016 00:21
Show Gist options
  • Save stephtdouglas/0cf6e5c12e4d37f59cfb to your computer and use it in GitHub Desktop.
Save stephtdouglas/0cf6e5c12e4d37f59cfb to your computer and use it in GitHub Desktop.
strided array
# Created by Brett Morris @bmorris3
# Saving for future use
def strided_array(a, window_width):
as_strided = np.lib.stride_tricks.as_strided
#window_width = 4
new_shape = (len(a) - window_width + 1, window_width)
b = as_strided(a, new_shape, (a.strides[0], a.strides[0]))
return b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment