[New-bugs-announce] [issue33494] random.choices ought to check that cumulative weights are in ascending order

Steven D'Aprano report at bugs.python.org
Mon May 14 07:36:38 EDT 2018


New submission from Steven D'Aprano <steve+python at pearwood.info>:

As mentioned on the Python-List:

https://mail.python.org/pipermail/python-list/2018-May/733061.html

random.choices() silently returns the wrong values when cumulative weights are not given, i.e. if the user misreads the documentation and provides non-cumulative weights, expecting that cumulative weights will be constructed for them.

I think that the documentation should be more clear, and preferably the choices() function ought to fail early when given invalid weights.

----------
components: Library (Lib)
messages: 316499
nosy: mark.dickinson, rhettinger, steven.daprano
priority: normal
severity: normal
status: open
title: random.choices ought to check that cumulative weights are in ascending order
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33494>
_______________________________________


More information about the New-bugs-announce mailing list