- last_bucket_start = bucket[0] # beginning of range
- if max_population is None or pop > max_population:
- max_population = pop # bucket with max items
-
+ details.num_populated_buckets += 1
+ details.last_bucket_start = start
+ if details.max_population is None or pop > details.max_population:
+ details.max_population = pop
+ if details.lowest_start is None or start < details.lowest_start:
+ details.lowest_start = start
+ if details.highest_end is None or end > details.highest_end:
+ details.highest_end = end
+ label = f'[{label_formatter}..{label_formatter}): ' % (start, end)
+ label_width = len(label)
+ if details.max_label_width is None or label_width > details.max_label_width:
+ details.max_label_width = label_width
+ return details
+
+ def __repr__(self, *, width: int = 80, label_formatter: str = '%d') -> str:
+ """Returns a pretty (text) representation of the histogram and
+ some vital stats about the population in it (min, max, mean,
+ median, mode, stdev, etc...)
+ """
+ from text_utils import BarGraphText, bar_graph_string
+
+ details = self._get_bucket_details(label_formatter)