Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: Fix random.uniform example comment. #25784

Merged
merged 1 commit into from May 3, 2021

Conversation

@JulienPalard
Copy link
Member

@JulienPalard JulienPalard commented May 1, 2021

Checked using:

>>> random.uniform(10.0 - sys.float_info.epsilon, 10.0)
10.0
@rhettinger
Copy link
Contributor

@rhettinger rhettinger commented May 1, 2021

Note, the example isn't using two different values.

>>> 10.0 - sys.float_info.epsilon == 10.0
True

Also, I think the docs should be left as-is. The intention was to create a half-open interval. In a small way, this make the docs slightly worse.

Are you responding to a reported user problem?

@JulienPalard
Copy link
Member Author

@JulienPalard JulienPalard commented May 2, 2021

Note, the example isn't using two different values.

That's right, nice catch. I'm trying to find an example:

from collections import Counter
import math
from random import uniform


start = 0
while True:
    stop = math.nextafter(start, math.inf)
    assert start != stop
    values = Counter([uniform(start, stop) for _ in range(100)])
    assert len(values) == 2
    assert start in values
    assert stop in values
    start = stop

I cannot find an example where the end is not included using the code above, do you have an example where the end is excluded?

Are you responding to a reported user problem?

Yes from docs@.

@rhettinger rhettinger merged commit 440c025 into python:master May 3, 2021
12 checks passed
12 checks passed
@github-actions
Docs
Details
@github-actions
Check for source changes
Details
@github-actions
Check if generated files are up to date
Details
@github-actions
Windows (x86)
Details
@github-actions
Windows (x64)
Details
@github-actions
macOS
Details
@github-actions
Ubuntu
Details
@github-actions
Ubuntu SSL tests with OpenSSL ${{ matrix.openssl_ver }}
Details
Azure Pipelines PR #20210501.54 succeeded
Details
@travis-ci
Travis CI - Pull Request Build Passed
Details
@bedevere-bot
bedevere/issue-number Issue report skipped
@bedevere-bot
bedevere/news "skip news" label found
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented May 3, 2021

Thanks @JulienPalard for the PR, and @rhettinger for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒🤖

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 3, 2021

GH-25843 is a backport of this pull request to the 3.9 branch.

miss-islington added a commit to miss-islington/cpython that referenced this pull request May 3, 2021
(cherry picked from commit 440c025)

Co-authored-by: Julien Palard <julien@palard.fr>
miss-islington added a commit that referenced this pull request May 3, 2021
(cherry picked from commit 440c025)


Co-authored-by: Julien Palard <julien@palard.fr>

Automerge-Triggered-By: GH:JulienPalard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants