From 0879a99172640815acf351110ced0ed48e236f6c Mon Sep 17 00:00:00 2001 From: arya2 Date: Thu, 26 Jan 2023 14:43:27 -0500 Subject: [PATCH 1/4] Adds floating point note in update_weights docs --- src/distributions/weighted_index.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/distributions/weighted_index.rs b/src/distributions/weighted_index.rs index b1b2071abc1..43e19353e13 100644 --- a/src/distributions/weighted_index.rs +++ b/src/distributions/weighted_index.rs @@ -141,6 +141,8 @@ impl WeightedIndex { /// allocation internally. /// /// In case of error, `self` is not modified. + /// + /// Note: Updating floating-point weights may cause slight inaccuracies in the total weight. 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> From 6bb6eb68d40d9cded78e6a1d887c9b8eead6deec Mon Sep 17 00:00:00 2001 From: Arya Date: Thu, 2 Feb 2023 01:10:17 -0500 Subject: [PATCH 2/4] Update src/distributions/weighted_index.rs --- src/distributions/weighted_index.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/distributions/weighted_index.rs b/src/distributions/weighted_index.rs index 43e19353e13..aec097702e7 100644 --- a/src/distributions/weighted_index.rs +++ b/src/distributions/weighted_index.rs @@ -143,6 +143,8 @@ impl WeightedIndex { /// In case of error, `self` is not modified. /// /// Note: Updating floating-point weights may cause slight inaccuracies in the total weight. + /// This method will not always 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> From 4151835f1a4187f6c17136d1f781c68503e03ffa Mon Sep 17 00:00:00 2001 From: Arya Date: Thu, 2 Feb 2023 01:12:26 -0500 Subject: [PATCH 3/4] Update src/distributions/weighted_index.rs --- src/distributions/weighted_index.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/distributions/weighted_index.rs b/src/distributions/weighted_index.rs index aec097702e7..9b74e690b3c 100644 --- a/src/distributions/weighted_index.rs +++ b/src/distributions/weighted_index.rs @@ -142,9 +142,10 @@ impl WeightedIndex { /// /// In case of error, `self` is not modified. /// +```suggestion /// Note: Updating floating-point weights may cause slight inaccuracies in the total weight. - /// This method will not always return `WeightedError::AllWeightsZero` when all weights - /// are zero if using floating-point weights. + /// 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> From 13a26a1686c787c9137a972568152edf4b963b98 Mon Sep 17 00:00:00 2001 From: Arya Date: Thu, 2 Feb 2023 01:13:41 -0500 Subject: [PATCH 4/4] Update src/distributions/weighted_index.rs --- src/distributions/weighted_index.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/distributions/weighted_index.rs b/src/distributions/weighted_index.rs index 9b74e690b3c..0131ed157c0 100644 --- a/src/distributions/weighted_index.rs +++ b/src/distributions/weighted_index.rs @@ -142,7 +142,6 @@ impl WeightedIndex { /// /// In case of error, `self` is not modified. /// -```suggestion /// 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.