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 IRomanowska
Recipients IRomanowska
Date 2019-11-21.17:35:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1574357722.81.0.985505977312.issue38881@roundup.psfhosted.org>
In-reply-to
Content
Hi, 
When zero weights are given, the last element of a sequence is always chosen. Example: 

hits= []
for i in range(100):
    hits.append(random.choices(["A","B","C","D"], [0, 0, 0, 0])[0])
print (set(hits))

>> {'D'}

I guess that most users would expect that in case of zero weights it will default into a random.choice behaviour and select one option at random since this is what happens in cases when all weights are equal. Alternatively, it should return an empty array if the assumption was that all choices have a zero probability of being selected. Either way, if it is consistently choosing one option, this may be potentially difficult to spot in situations when a sequence of weights all equal to zero only happen sporadically.
History
Date User Action Args
2019-11-21 17:35:22IRomanowskasetrecipients: + IRomanowska
2019-11-21 17:35:22IRomanowskasetmessageid: <1574357722.81.0.985505977312.issue38881@roundup.psfhosted.org>
2019-11-21 17:35:22IRomanowskalinkissue38881 messages
2019-11-21 17:35:22IRomanowskacreate