-
Notifications
You must be signed in to change notification settings - Fork 432
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
Rename WeightedError → WeightError; add IndexedRandom, IndexedMutRandom #1382
Conversation
This no longer panics and now returns an error when not enough weights are positive.
I took a general look at 06fe3d8 (the commit where you split Unless I'm missing something (it's been a while since I touched
Personally, I'm a fan of this solution. Not only does it make it possible for non-std collections to implement random functionality, but it makes it as simple as impl-ing one method on one trait. Still, if you come up with a better idea, don't be afraid to poke me and I'll tell you what I think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Thanks @TheIronBorn |
Fixes #1307. CC @LikeLakers2.
Renames
WeightedError
→WeightError
, revises variants and re-exports fromrand::seq
.Adjusts
WeightError
cases:WeightedTreeIndex
(NaNs andtry_sample
@xmakro) andrand::seq::index::sample_weighted
(replace panic; catch too-many-zeros).Splits
SliceRandom
into multiple traits to solve #1307. I'm not wildly keen on the result but don't currently have a better idea.