Skip to content

Commit

Permalink
Add note about floating point weights in update_weights docs (#1280)
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 authored Feb 2, 2023
1 parent 4bde8a0 commit ae4b48e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/distributions/weighted_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ impl<X: SampleUniform + PartialOrd> WeightedIndex<X> {
/// allocation internally.
///
/// In case of error, `self` is not modified.
///
/// Note: Updating floating-point weights may cause slight inaccuracies in the total weight.
/// This method may not return `WeightedError::AllWeightsZero` when all weights
/// are zero if using floating-point weights.
pub fn update_weights(&mut self, new_weights: &[(usize, &X)]) -> Result<(), WeightedError>
where X: for<'a> ::core::ops::AddAssign<&'a X>
+ for<'a> ::core::ops::SubAssign<&'a X>
Expand Down

0 comments on commit ae4b48e

Please sign in to comment.