From 3b674449117bb0b7bdd93715fcb6aac577fa6ac6 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Wed, 9 Feb 2022 16:32:49 +0000 Subject: [PATCH] Update Sparkline.summary_func -> summary_function --- src/textual/renderables/sparkline.py | 8 ++++---- tests/renderables/test_sparkline.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/textual/renderables/sparkline.py b/src/textual/renderables/sparkline.py index a24630580..1de571c4d 100644 --- a/src/textual/renderables/sparkline.py +++ b/src/textual/renderables/sparkline.py @@ -19,7 +19,7 @@ class Sparkline: width (int, optional): The width of the sparkline/the number of buckets to partition the data into. min_color (Color, optional): The color of values equal to the min value in data. max_color (Color, optional): The color of values equal to the max value in data. - summary_func (Callable[list[T]]): Function that will be applied to each bucket. + summary_function (Callable[list[T]]): Function that will be applied to each bucket. """ BARS = "▁▂▃▄▅▆▇█" @@ -31,13 +31,13 @@ class Sparkline: width: int | None, min_color: Color = Color.from_rgb(0, 255, 0), max_color: Color = Color.from_rgb(255, 0, 0), - summary_func: Callable[[list[T]], float] = max, + summary_function: Callable[[list[T]], float] = max, ) -> None: self.data = data self.width = width self.min_color = Style.from_color(min_color) self.max_color = Style.from_color(max_color) - self.summary_func = summary_func + self.summary_func = summary_function @classmethod def _buckets(cls, data: Sequence[T], num_buckets: int) -> Iterable[list[T]]: @@ -122,6 +122,6 @@ if __name__ == "__main__": console.print(f"data = {nums}\n") for f in funcs: console.print( - f"{f.__name__}:\t", Sparkline(nums, width=12, summary_func=f), end="" + f"{f.__name__}:\t", Sparkline(nums, width=12, summary_function=f), end="" ) console.print("\n") diff --git a/tests/renderables/test_sparkline.py b/tests/renderables/test_sparkline.py index 0e426ebe9..74f1f2f6b 100644 --- a/tests/renderables/test_sparkline.py +++ b/tests/renderables/test_sparkline.py @@ -34,7 +34,7 @@ def test_sparkline_shrink_data_to_width(): def test_sparkline_shrink_data_to_width_non_divisible(): assert render( - Sparkline([1, 2, 3, 4, 5], width=3, summary_func=min)) == f"{GREEN}▁{STOP}{BLENDED}▄{STOP}{RED}█{STOP}" + Sparkline([1, 2, 3, 4, 5], width=3, summary_function=min)) == f"{GREEN}▁{STOP}{BLENDED}▄{STOP}{RED}█{STOP}" def test_sparkline_color_blend():