[issue38881] unexpected behaviour of random.choices with zero weights
Raymond Hettinger
report at bugs.python.org
Thu Nov 21 23:25:29 EST 2019
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
> When zero weights are given, the last element of a sequence
> is always chosen.
Given non-sensical input, that behavior is as reasonable as any other (fwiw, the same is also observed with all negative weights, even if the negative weights are unequal).
The documentation currently says, "weights are assumed to be non-negative." Perhaps it should say, "weights are assumed to be non-negative and have at least one positive weight."
----------
assignee: -> rhettinger
components: +Documentation -Library (Lib)
versions: +Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38881>
_______________________________________
More information about the Python-bugs-list
mailing list