[issue40569] Add optional weights to random.sample()
David Heiberg added the comment: Just playing around with this and I think one thing to consider is how to handle negative weights. Should they even be allowed? One interesting behaviour I encountered with the current draft is the following: >>> r.sample(['katniss', 'prim', 'gale', 'peeta'] , weights=[-2,1,1,1], k=1) ['peeta'] This will always return ['peeta'], or whatever happens to be in the last index. I believe this is because in `choices`, the `cum_weights` list would be [-2, -1, 0, 1], causing it to only be able to select the last value in the population. Looking into random.choices, it suggests that the weights were designed with negative ones in mind. However they were not accounted for and end up influencing the weights of the indexes around it. Another example is this: >>> r.choices(['alice', 'bob', 'camile', 'david'], weights=[1, 1, -2, 1]) ['alice'] This will always return ['alice'], showing that the negative weight of 'camile' is affecting indexes around it. Is there something I am missing? Otherwise this seems like it may warrant its own bug. -- nosy: +dheiberg ___ Python tracker <https://bugs.python.org/issue40569> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40569] Add optional weights to random.sample()
David Heiberg added the comment: Ahh I see, thanks for clearing that up! On Sun, May 10, 2020, 04:41 Raymond Hettinger wrote: > > Raymond Hettinger added the comment: > > Negative weights are undefined for choices() as well. Just like bisect() > and merge() don't verify their inputs are sorted. Usually, full scan > precondition checks are expensive in pure python and aren't worth > penalizing correct code. As Henk-Jaap points-out, negative weights are just > a special case of meaningless inputs. > > -- > > ___ > Python tracker > <https://bugs.python.org/issue40569> > ___ > -- ___ Python tracker <https://bugs.python.org/issue40569> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37730] NotImplemented is used instead of NotImplementedError in docs
David Heiberg added the comment: I'm happy to take a look at this, I found one example here: https://docs.python.org/3/library/winreg.html#winreg.DisableReflectionKey How would I go about submitting a patch for all of the docs across the versions? Would I apply the patch to the relevant branches and submit a PR for each? Still fairly new to this, thanks for any pointers! -- nosy: +dheiberg ___ Python tracker <https://bugs.python.org/issue37730> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37730] NotImplemented is used instead of NotImplementedError in docs
David Heiberg added the comment: Super, thanks for the help, I'll submit a PR as soon as it is ready -- ___ Python tracker <https://bugs.python.org/issue37730> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37730] NotImplemented is used instead of NotImplementedError in docs
Change by David Heiberg : -- keywords: +patch pull_requests: +14811 stage: -> patch review pull_request: https://github.com/python/cpython/pull/15062 ___ Python tracker <https://bugs.python.org/issue37730> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37730] NotImplemented is used instead of NotImplementedError in docs
Change by David Heiberg : -- pull_requests: +14872 pull_request: https://github.com/python/cpython/pull/15133 ___ Python tracker <https://bugs.python.org/issue37730> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35448] ConfigParser .read() - handling of nonexistent files
Change by David Heiberg : -- nosy: +dheiberg ___ Python tracker <https://bugs.python.org/issue35448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
David Heiberg added the comment: Since there has been no objection to this yet, would it be alright for me to take this as my first PR? On top of the change you mentioned to the __slots__ list, should there also be a test written so that a similar regression doesn't happen again? -- nosy: +dheiberg ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
David Heiberg added the comment: Ok thanks for your input, I will work on a PR and hopefully submit one tomorrow or Wednesday depending on schedule. -- ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
Change by David Heiberg : -- keywords: +patch pull_requests: +11236 stage: needs patch -> patch review ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
Change by David Heiberg : -- keywords: +patch, patch pull_requests: +11236, 11237 stage: needs patch -> patch review ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
Change by David Heiberg : -- keywords: +patch, patch, patch pull_requests: +11236, 11237, 11238 stage: needs patch -> patch review ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
David Heiberg added the comment: Ahh yes of course, I will remove that from the notes. With regards to the second note, would it do any harm to leave it in? I suppose it does imply that this was possible before... -- ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
David Heiberg added the comment: Should the note on arbitrary attributes also be removed? If this was documented previously then I don't see the need for it here, but if this has never been documented then maybe some other way of wording it may be sensible to include? -- ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
David Heiberg added the comment: Agreed. I will fix the documentation and submit a PR this weekend hopefully. -- ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
Change by David Heiberg : -- pull_requests: +11374, 11375, 11376 stage: needs patch -> patch review ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
Change by David Heiberg : -- pull_requests: +11374, 11375 stage: needs patch -> patch review ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
Change by David Heiberg : -- pull_requests: +11374 stage: needs patch -> patch review ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5038] urrlib2/httplib doesn't reset file position between requests
Change by David Heiberg : -- nosy: +dheiberg ___ Python tracker <https://bugs.python.org/issue5038> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35701] [uuid] 3.8 breaks weak references for UUIDs
David Heiberg added the comment: I have submitted a PR for the documentation. Hopefully this is enough to resolve the issue and close. -- ___ Python tracker <https://bugs.python.org/issue35701> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com