[issue42944] random.Random.sample bug when counts is not None

2021-01-18 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks for the report and the PR.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42944] random.Random.sample bug when counts is not None

2021-01-18 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset a90539f5723a4c34430761be8cba97daa8474abf by Miss Islington (bot) 
in branch '3.9':
bpo-42944 Fix Random.sample when counts is not None (GH-24235) (GH-24243)
https://github.com/python/cpython/commit/a90539f5723a4c34430761be8cba97daa8474abf


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42944] random.Random.sample bug when counts is not None

2021-01-18 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +23065
pull_request: https://github.com/python/cpython/pull/24243

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42944] random.Random.sample bug when counts is not None

2021-01-18 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset f7b5bacd7a0b2084ce699eda6f6f4b1adfa16590 by jonanifranco in 
branch 'master':
bpo-42944 Fix Random.sample when counts is not None (GH-24235)
https://github.com/python/cpython/commit/f7b5bacd7a0b2084ce699eda6f6f4b1adfa16590


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42944] random.Random.sample bug when counts is not None

2021-01-17 Thread Jon FRANCO


Jon FRANCO  added the comment:

PR submitted. 
Let me know if I missed something, this is also my first PR.
Regards.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42944] random.Random.sample bug when counts is not None

2021-01-17 Thread Jon FRANCO


Change by Jon FRANCO :


--
keywords: +patch
pull_requests: +23058
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24235

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42944] random.Random.sample bug when counts is not None

2021-01-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Would you like to submit a PR for this?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42944] random.Random.sample bug when counts is not None

2021-01-16 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42944] random.Random.sample bug when counts is not None

2021-01-16 Thread Jon FRANCO


New submission from Jon FRANCO :

Hello,

If I am reading right, random.Random.sample method has a bug if counts is not 
None.

Line 482 (of master):
"""
selections = sample(range(total), k=k)
"""
this is calling the module function 'sample' and not the instance method.

IMO this line should be:
"""
selections = self.sample(range(total), k=k)
"""

Python 3.9.1 (default, Dec 11 2020, 14:32:07) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from random import Random
>>> r = Random()
>>> r.seed('bug')
>>> r.sample(range(50), 5, counts=range(1,51))
[34, 39, 31, 42, 38]
>>> r.seed('bug')
>>> r.sample(range(50), 5, counts=range(1,51))
[39, 11, 3, 12, 29]  <== this should be [34, 39, 31, 42, 38]
>>> r.seed('nobug')
>>> r.sample(range(50), 5)
[0, 30, 23, 17, 49]
>>> r.seed('nobug')
>>> r.sample(range(50), 5)
[0, 30, 23, 17, 49]

Regards,
Jon FRANCO

--
components: Library (Lib)
messages: 385152
nosy: jonfranco, rhettinger
priority: normal
severity: normal
status: open
title: random.Random.sample bug when counts is not None
type: behavior
versions: Python 3.10, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com