This commit is contained in:
Nitzan Shaked
2023-01-02 21:58:23 +02:00
parent 5750666ad8
commit c1a90c25a1
3 changed files with 12 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ T = TypeVar("T", int, float)
SummaryFunction = Callable[[Sequence[T]], float]
class Sparkline(Generic[T]):
"""A sparkline representing a series of data.
@@ -100,7 +101,13 @@ if __name__ == "__main__":
def last(l: Sequence[T]) -> T:
return l[-1]
funcs: Sequence[SummaryFunction[int]] = (min, max, last, statistics.median, statistics.mean)
funcs: Sequence[SummaryFunction[int]] = (
min,
max,
last,
statistics.median,
statistics.mean,
)
nums = [10, 2, 30, 60, 45, 20, 7, 8, 9, 10, 50, 13, 10, 6, 5, 4, 3, 7, 20]
console.print(f"data = {nums}\n")
for f in funcs:

View File

@@ -63,8 +63,7 @@ class TextOpacity:
_from_color = Style.from_color
if opacity == 0:
for text, style, control in cast(
Iterable[tuple[str, Style, object]],
segments
Iterable[tuple[str, Style, object]], segments
):
assert style is not None
invisible_style = _from_color(bgcolor=style.bgcolor)

View File

@@ -628,7 +628,9 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
root = self.root
def add_node(path: list[TreeNode[TreeDataType]], node: TreeNode[TreeDataType], last: bool) -> None:
def add_node(
path: list[TreeNode[TreeDataType]], node: TreeNode[TreeDataType], last: bool
) -> None:
child_path = [*path, node]
node._line = len(lines)
add_line(TreeLine(child_path, last))