question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move `sliding_window_view` to the main module and add `step_size`

See original GitHub issue
  1. 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 doing import from is a bit inconvenient)
  2. 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:open
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
eric-wiesercommented, Jan 27, 2021

I argued against step_size when we designed this function, because you can get that behavior already with sliding_window_view(x, 3)[::2].

0reactions
rgommerscommented, Aug 1, 2021

Hi @rgommers, I’m curious to know if there has been any development regarding the mentioned reorganization?

gh-18447 made some initial steps, but it seems to have stalled.

if possible I would suggest renaming it to window.

That’s way too generic a name; even in numpy itself we have other “window functions” like bartlett, hanning, etc.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found