Skip to content

Commit cf5e816

Browse files
OWFeatureStatistics: Zeros always positive and clipped to two decimals
1 parent 28a2e6e commit cf5e816

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Orange/widgets/data/owfeaturestatistics.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,22 @@ def decoration():
493493

494494
def display():
495495
# pylint: disable=too-many-branches
496+
def format_zeros(str_val):
497+
"""Zeros should be handled separately as they cannot be negative."""
498+
if float(str_val) == 0:
499+
num_decimals = min(self.variables[row].number_of_decimals, 2)
500+
str_val = f"{0:.{num_decimals}f}"
501+
return str_val
502+
496503
def render_value(value):
497-
return "" if np.isnan(value) else attribute.str_val(value)
504+
if np.isnan(value):
505+
return ""
506+
507+
str_val = attribute.str_val(value)
508+
if attribute.is_continuous:
509+
str_val = format_zeros(str_val)
510+
511+
return str_val
498512

499513
if column == self.Columns.NAME:
500514
return attribute.name

0 commit comments

Comments
 (0)