Message377618
I've discussed this with other developers and now agree that a test should be added. While the current code's handing of Inf or NaN is correct in a technical sense, it is neither intuitive or useful.
Even though it will have a small time cost for the common case of two weights, we should add a test just after the check for the total being greater than zero:
if not _isfinite(total):
raise ValueError('Total of weights must be finite')
Also edit the docs to say:
Weights are assumed to be non-negative and finite.
Ram, since this was your finding, do you want to make a PR for it (with a test, news entry, and doc edit)? |
|
Date |
User |
Action |
Args |
2020-09-28 20:04:47 | rhettinger | set | recipients:
+ rhettinger, cool-RR |
2020-09-28 20:04:47 | rhettinger | set | messageid: <1601323487.75.0.580042052322.issue41773@roundup.psfhosted.org> |
2020-09-28 20:04:47 | rhettinger | link | issue41773 messages |
2020-09-28 20:04:47 | rhettinger | create | |
|