From 7ff2af6fe7bffea90dc4a31c93140c189917c659 Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 2 Feb 2022 13:47:36 -0800 Subject: Let's be explicit with asserts; there was a bug in histogram caused by assert foo when foo was an int with valid valid 0. --- histogram.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'histogram.py') diff --git a/histogram.py b/histogram.py index d45e93f..cea8b76 100644 --- a/histogram.py +++ b/histogram.py @@ -81,7 +81,7 @@ class SimpleHistogram(Generic[T]): last_bucket_start = bucket[0] # beginning of range if max_population is None or pop > max_population: max_population = pop # bucket with max items - if max_population is None: + if len(self.buckets) == 0 or max_population is None: return txt max_label_width: Optional[int] = None @@ -100,9 +100,9 @@ class SimpleHistogram(Generic[T]): max_label_width = label_width if start == last_bucket_start: break - assert max_label_width - assert lowest_start - assert highest_end + assert max_label_width is not None + assert lowest_start is not None + assert highest_end is not None sigma_label = f'[{label_formatter}..{label_formatter}): ' % ( lowest_start, -- cgit v1.3