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

Re-org with distr::slice, distr::weighted modules #1548

Merged
merged 17 commits into from
Jan 14, 2025

Conversation

dhardy
Copy link
Member

@dhardy dhardy commented Jan 9, 2025

  • Added a CHANGELOG.md entry

Summary

Re-organise / rename a few things in rand::distr and rand_distr:

  • Move Slice -> slice::Choose, EmptySlice -> slice::Empty
  • Rename trait DistString -> SampleString
  • Rename DistIter -> Iter, DistMap -> Map
  • Move {Weight, WeightError, WeightedIndex} -> weighted::{Weight, Error, WeightedIndex}
  • Move weighted_alias::{AliasableWeight, WeightedAliasIndex} -> weighted::{..}
  • Move weighted_tree::WeightedTreeIndex -> weighted::WeightedTreeIndex

Motivation

Some things like Slice and DistString weren't that obvious from the name. Now I find the purpose clearer from the path.

For rand_distr, all weighted distributions are now under a single module which is better for doc and shared stuff like Weight. (Possibly we should go further and move them all to a new crate? But maybe not since rand::seq::IndexedRandom also supports weighted sampling.)

Possibly more re-organisation of rand_distr is justified. The "flat organisation" system works well enough though.

Copy link
Collaborator

@benjamin-lieser benjamin-lieser left a comment

Choose a reason for hiding this comment

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

It looks fine to me (minus the two comments on the CI) and I think it makes sense to organize it in this way.

@dhardy dhardy merged commit b4b1eb7 into rust-random:master Jan 14, 2025
17 checks passed
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