Message354030
The premature return on ZeroDivisionError also causes an inconsistency in how types are handled. For example,
>>> harmonic_mean([1, 0, "foo"])
0
We get an error as expected if "foo" occurs before 0:
>>> harmonic_mean([1, "foo", 0])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in harmonic_mean
T, total, count = _sum(1/x for x in _fail_neg(data, errmsg))
File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 166, in _sum
for n,d in map(_exact_ratio, values):
File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 406, in <genexpr>
T, total, count = _sum(1/x for x in _fail_neg(data, errmsg))
File "/Users/warren/repos/git/forks/cpython/Lib/statistics.py", line 288, in _fail_neg
if x < 0:
TypeError: '<' not supported between instances of 'str' and 'int' |
|
Date |
User |
Action |
Args |
2019-10-06 02:40:20 | WarrenWeckesser | set | recipients:
+ WarrenWeckesser |
2019-10-06 02:40:20 | WarrenWeckesser | set | messageid: <1570329620.36.0.696849357019.issue38382@roundup.psfhosted.org> |
2019-10-06 02:40:20 | WarrenWeckesser | link | issue38382 messages |
2019-10-06 02:40:20 | WarrenWeckesser | create | |
|