X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=histogram.py;h=f85abea2c45f05ef65c70657bd1b2b6f53f04c04;hb=e8fbbb7306430478dec55d2c963eed116d8330cc;hp=cea8b766e3f88a3e197cbdff128539f199fdc83a;hpb=7ff2af6fe7bffea90dc4a31c93140c189917c659;p=python_utils.git diff --git a/histogram.py b/histogram.py index cea8b76..f85abea 100644 --- a/histogram.py +++ b/histogram.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +"""A text-based simple histogram helper class.""" import math -from numbers import Number from typing import Dict, Generic, Iterable, List, Optional, Tuple, TypeVar T = TypeVar("T", int, float) @@ -10,6 +12,8 @@ Count = int class SimpleHistogram(Generic[T]): + """A simple histogram.""" + # Useful in defining wide open bottom/top bucket bounds: POSITIVE_INFINITY = math.inf NEGATIVE_INFINITY = -math.inf @@ -81,7 +85,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 len(self.buckets) == 0 or max_population is None: + if max_population is None: return txt max_label_width: Optional[int] = None