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

Method chunks

funct/Array.py:622–630  ·  view source on GitHub ↗

Splits this Array into chunks of size n. If `drop_last` is True, drops the last subarray if the split results in an inequal division.

(self, n, drop_last=False)

Source from the content-addressed store, hash-verified

620 return Array(self[n[i] : n[i + 1]] for i in range(n.size - 1))
621
622 def chunks(self, n, drop_last=False):
623 """
624 Splits this Array into chunks of size n.
625 If `drop_last` is True, drops the last subarray if the split
626 results in an inequal division.
627 """
628 self.__validate_bool_arg(drop_last, "drop_last")
629 fun = int if drop_last else math.ceil
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 """

Callers

nothing calls this directly

Calls 2

__validate_bool_argMethod · 0.95
ArrayClass · 0.85

Tested by

no test coverage detected