79664296

Date: 2025-06-13 02:49:02
Score: 1
Natty:
Report link

I'd recommend using sliding_window_view. Change:

nStencil = 3
x_neighbours = (
   x[indexStart:indexStop]
   for indexStart, indexStop in zip(
      (None, *range(1,nStencil)),
      (*range(1-nStencil,0), None),
   )
)

To:

nStencil = 3
sliding_view = sliding_window_view(x, nStencil) 
x_neighbours = tuple(sliding_view[:, i] for i in range(nStencil))
Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Pratik Mathur