mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add docstring to buckets method
This commit is contained in:
@@ -41,6 +41,13 @@ class Sparkline:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _buckets(cls, data: Sequence[T], num_buckets: int) -> Iterable[list[T]]:
|
def _buckets(cls, data: Sequence[T], num_buckets: int) -> Iterable[list[T]]:
|
||||||
|
"""Partition ``data`` into ``num_buckets`` buckets. For example, the data
|
||||||
|
[1, 2, 3, 4] partitioned into 2 buckets is [[1, 2], [3, 4]].
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data (Sequence[T]): The data to partition.
|
||||||
|
num_buckets (int): The number of buckets to partition the data into.
|
||||||
|
"""
|
||||||
num_steps, remainder = divmod(len(data), num_buckets)
|
num_steps, remainder = divmod(len(data), num_buckets)
|
||||||
for i in range(num_buckets):
|
for i in range(num_buckets):
|
||||||
start = i * num_steps + min(i, remainder)
|
start = i * num_steps + min(i, remainder)
|
||||||
|
|||||||
Reference in New Issue
Block a user