Skip to content

Commit 7eed882

Browse files
committed
statistics: Fix geometric_mean() error message for negative inputs
The error message was constructed with two positional arguments to StatisticsError, causing str(e) to display as a tuple: "('No negative inputs allowed', -2.0)". Use an f-string instead so the value is embedded directly in the message string.
1 parent 60b751c commit 7eed882

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Lib/statistics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def count_positive(iterable):
248248
elif x == 0.0:
249249
found_zero = True
250250
else:
251-
raise StatisticsError('No negative inputs allowed', x)
251+
raise StatisticsError(f'No negative inputs allowed: {x!r}')
252252

253253
total = fsum(map(log, count_positive(data)))
254254

0 commit comments

Comments
 (0)