MCPcopy Create free account
hub / github.com/Lauriat/funct / windows

Method windows

funct/Array.py:632–640  ·  view source on GitHub ↗

Returns sliding windows of width `size` over the Array. If `drop_last` is True, drops the last subarrays that are shorter than the window size.

(self, size, stride=1, drop_last=True)

Source from the content-addressed store, hash-verified

630 return Array(self[i * n : (i + 1) * n] for i in range(fun(self.size / n)))
631
632 def windows(self, size, stride=1, drop_last=True):
633 """
634 Returns sliding windows of width `size` over the Array.
635 If `drop_last` is True, drops the last subarrays that are
636 shorter than the window size.
637 """
638 self.__validate_bool_arg(drop_last, "drop_last")
639 end = (self.size - size + 1) if drop_last else self.size
640 return Array(self[i : i + size] for i in range(0, end, stride))
641
642 def takeWhile(self, l):
643 """ Takes the longest prefix of elements that satisfy the given predicate. """

Callers

nothing calls this directly

Calls 2

__validate_bool_argMethod · 0.95
ArrayClass · 0.85

Tested by

no test coverage detected