From 7fe0d4e1170bbd6ba370d7bcdaf28213fa7e931a Mon Sep 17 00:00:00 2001 From: Ivan Pesin Date: Sat, 29 Nov 2025 18:45:38 +0200 Subject: [PATCH] Handle histogram max int --- termgraph/chart.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/termgraph/chart.py b/termgraph/chart.py index 679ffd5..ae19130 100644 --- a/termgraph/chart.py +++ b/termgraph/chart.py @@ -189,7 +189,7 @@ def _normalize(self) -> list[list[float]]: if self.data.dims and len(self.data.dims) > 1: for i in range(self.data.dims[1]): cat_data = [[dat[i]] for dat in self.data.data] - + # Create temporary Data object for category data from .data import Data temp_data = Data(cat_data, [f"cat_{j}" for j in range(len(cat_data))]) @@ -509,6 +509,11 @@ def draw(self) -> None: count_list.append([count]) + # Handle the case where the maximum value is exactly equal to the upper border + # Calculate total number of max values and add them to the last bin + count = sum(1 for row in self.data.data for v in row if v == class_max) + count_list[-1][0] += count + width_arg = self.args.get_arg("width") if isinstance(width_arg, int): width = width_arg