Move `sliding_window_view` to the main module and add `step_size`
See original GitHub issue- Writing
np.lib.stride_tricks.sliding_window_view
is a bit of a mouthful, I think it would be better if it was placed inside the main module. (also doingimport from
is a bit inconvenient) - I suggest adding a
step_size
parameter to the function, an example of its use would be:
x = np.arange(10)
sliding_window_view(x, 3, step_size=2)
>> array([[0, 1, 2],
[2, 3, 4],
[4, 5, 6],
[6, 7, 8]])
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
numpy.lib.stride_tricks.sliding_window_view
Create a sliding window view into the array with the given window shape. Also known as rolling or moving window, the window slides...
Read more >Taking subarrays from numpy array with given stride/stepsize
Approach #1 : Using broadcasting - def broadcasting_app(a, L, S ): # Window len = L, Stride len/stepsize = S nrows = ((a.size-L)//S)+1...
Read more >Suggestion: Sliding Window Function · Issue #7753 - GitHub
For example a moving average of a window length 3 , stepsize 1 : a = numpy.arange(10) a_strided = numpy.lib.stride_tricks.as_strided( a, ...
Read more >Python Sliding Windows Of A List - ADocLib
Create a sliding window view into the array with the given window shape. ... Python Code for a Vectorized Moving Window on a...
Read more >minchaoln/100-numpy-exercises - Jovian
How to get the documentation of the numpy add function from the command line? () ... and k<0 for diagonals below the main...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I argued against step_size when we designed this function, because you can get that behavior already with
sliding_window_view(x, 3)[::2]
.gh-18447 made some initial steps, but it seems to have stalled.
That’s way too generic a name; even in numpy itself we have other “window functions” like
bartlett
,hanning
, etc.