This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cool-RR
Recipients cool-RR
Date 2020-09-12.15:31:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1599924677.89.0.407491787221.issue41773@roundup.psfhosted.org>
In-reply-to
Content
I was recently tripped up by a bug caused by passing infinite weights to random.choices. I toyed around with that function, and it seemed that when it's given weights that include infinity or NaN, it selects a specific element, always without being random. That's regardless of whether multiple items have infinity weights. It chooses a different specific item if the infinity is negative. The specific item isn't always the one that has the infinite weight.

I don't know whether that's the intended behavior for some reason, or whether it's even possible to define a logical behavior for infinite weights. If it's not possible, then maybe this function should raise an errors when given weights that include infinity or nan.

I see that the documentation states that the weights must be non-negative; maybe we should have a check for that too.
History
Date User Action Args
2020-09-12 15:31:17cool-RRsetrecipients: + cool-RR
2020-09-12 15:31:17cool-RRsetmessageid: <1599924677.89.0.407491787221.issue41773@roundup.psfhosted.org>
2020-09-12 15:31:17cool-RRlinkissue41773 messages
2020-09-12 15:31:17cool-RRcreate