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

Fix: UniformIntGenerator range error #7143

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

sunbuny
Copy link

@sunbuny sunbuny commented Jan 22, 2025

Fix the UniformIntGenerator output range error. According to the function description, the output range should be [low, high), but the actual output range is [low, high].
refer to: uniform_int_distribution

Type

  • Bug fix (non-breaking change which fixes an issue): Fixes #
  • New feature (non-breaking change which adds functionality). Resolves #
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #

Motivation and Context

Fix the UniformIntGenerator output range error.

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

Copy link

update-docs bot commented Jan 22, 2025

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

@sunbuny
Copy link
Author

sunbuny commented Jan 22, 2025

Maybe we need to update the function description, because there are some usage of the this function in Open3D, but they are in the correct way.

@timohl
Copy link
Contributor

timohl commented Jan 22, 2025

Would it then maybe make sense to also change this validation check to conform to std::uniform_int_distribution?

if (low >= high) {
utility::LogError("low must be < high, but got low={} and high={}.",
low, high);

since the C++ docs state:

The behavior is undefined if a > b

@sunbuny sunbuny closed this Jan 23, 2025
@sunbuny sunbuny reopened this Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants