Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

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)?

----------
resolution: not a bug -> 
status: closed -> open
type: behavior -> enhancement

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41773>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to