[issue33114] random.sample() behavior is unexpected/unclear from docs

2018-03-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: > However, let me argue my case one more time, and if you still disagree, feel > free to close this. Thank you for expressing your ideas so clearly. However, I'm going to go with Tim's recommendation and leave the docs as

[issue33114] random.sample() behavior is unexpected/unclear from docs

2018-03-26 Thread Scott Eilerman
Scott Eilerman added the comment: Raymond, Tim, thanks for your replies so far. I understand (and for the most part, agree with) your points about not being able to list every behavior, and not wanting to cause uncertainty in users. However, let me argue my case

[issue33114] random.sample() behavior is unexpected/unclear from docs

2018-03-25 Thread Tim Peters
Tim Peters added the comment: There's nothing in the docs I can see that implies `sample(x, n)` is a prefix of what `sample(x, n+1)` would have returned had the latter been called instead. If so, then - as always - it's "at your own risk" when you rely on behaviors that

[issue33114] random.sample() behavior is unexpected/unclear from docs

2018-03-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Something along the lines of: "For a fixed seed, random.sample(population, k) > is not guaranteed to return the same samples for different values of k." In a way, the proposed wording succinctly directly addresses the problem

[issue33114] random.sample() behavior is unexpected/unclear from docs

2018-03-21 Thread Scott Eilerman
Scott Eilerman added the comment: Sorry, there's a typo in that example. It should look like: random.seed(fixed_seed) random.sample(choices, n)[-1] Then, later, I want the next draw, so I did: random.seed(fixed_seed) random.sample(choices, n+1)[-1] --

[issue33114] random.sample() behavior is unexpected/unclear from docs

2018-03-21 Thread Scott Eilerman
Scott Eilerman added the comment: To clarify the use case where this behavior was problematic for me, I wanted to get the nth random draw from a given distribution, so I used something like: random.seed(fixed_seed) random.sample(choices, n)[-1] Then, later, I want

[issue33114] random.sample() behavior is unexpected/unclear from docs

2018-03-21 Thread Scott Eilerman
Scott Eilerman added the comment: Something along the lines of: "For a fixed seed, random.sample(population, k) is not guaranteed to return the same samples for different values of k." -- ___ Python tracker

[issue33114] random.sample() behavior is unexpected/unclear from docs

2018-03-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: What additional wording do you propose? -- assignee: docs@python -> rhettinger nosy: +rhettinger ___ Python tracker

[issue33114] random.sample() behavior is unexpected/unclear from docs

2018-03-21 Thread Scott Eilerman
New submission from Scott Eilerman : I ran into a "bug" when using random.sample() in which I got some results I didn't expect. After digging a little more, this is either a side effect of the optimization that's made when k > 5, or I am using the function in a way