Skip to content
New issue

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

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

Already on GitHub? # to your account

Clarify documentation of choose_weighted(_mut) mentioning accurate behavior with floats #1245

Merged
merged 4 commits into from
Oct 10, 2022

Conversation

ISibboI
Copy link
Contributor

@ISibboI ISibboI commented Aug 2, 2022

Changes as discussed in this comment in #1243

  • Updates the choose_weighted (and similar) methods to have links to the WeightedIndex distribution.
  • Removes any links to deprecated modules
  • Explicitly mentions that zero weights (for floats and ints) are handled correctly, perhaps right before the example using weights of zero in the WeightedIndex docs.

I added the mention of zero weight in the first paragraph of the documentation.

Additionally

  • I fixed two minor issues in the docs of WeightedIndex and
  • changed the example that includes a weight of zero to use floating point numbers.

Feel free to request changes, this is my first contribution to this repository, so I don't really see the big picture.

Closes #1243

@ISibboI ISibboI marked this pull request as ready for review August 2, 2022 12:51
Copy link
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks very good. (Sorry for the delay!)

@dhardy dhardy merged commit 8d70f50 into rust-random:master Oct 10, 2022
@ISibboI
Copy link
Contributor Author

ISibboI commented Oct 10, 2022

No worries, thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is the SliceRandom::choose_weighted(...) method guaranteed to never choose an entry if it has zero weight?
2 participants