MCPcopy Index your code
hub / github.com/pydata/xarray / __iter__

Method __iter__

xarray/computation/rolling.py:307–324  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

305 self.window_labels = self.obj[self.dim[0]]
306
307 def __iter__(self) -> Iterator[tuple[DataArray, DataArray]]:
308 if self.ndim > 1:
309 raise ValueError("__iter__ is only supported for 1d-rolling")
310
311 dim0 = self.dim[0]
312 window0 = int(self.window[0])
313 offset = (window0 + 1) // 2 if self.center[0] else 1
314 stops = np.arange(offset, self.obj.sizes[dim0] + offset)
315 starts = stops - window0
316 starts[: window0 - offset] = 0
317
318 for label, start, stop in zip(self.window_labels, starts, stops, strict=True):
319 window = self.obj.isel({dim0: slice(start, stop)})
320
321 counts = window.count(dim=[dim0])
322 window = window.where(counts >= self.min_periods)
323
324 yield (label, window)
325
326 @_deprecate_positional_args("v2024.11.0")
327 def construct(

Callers

nothing calls this directly

Calls 4

arangeMethod · 0.80
iselMethod · 0.45
countMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected