Skip to content

Commit ae4b48e

Browse files
authored
Add note about floating point weights in update_weights docs (#1280)
1 parent 4bde8a0 commit ae4b48e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/distributions/weighted_index.rs

+4
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ impl<X: SampleUniform + PartialOrd> WeightedIndex<X> {
141141
/// allocation internally.
142142
///
143143
/// In case of error, `self` is not modified.
144+
///
145+
/// Note: Updating floating-point weights may cause slight inaccuracies in the total weight.
146+
/// This method may not return `WeightedError::AllWeightsZero` when all weights
147+
/// are zero if using floating-point weights.
144148
pub fn update_weights(&mut self, new_weights: &[(usize, &X)]) -> Result<(), WeightedError>
145149
where X: for<'a> ::core::ops::AddAssign<&'a X>
146150
+ for<'a> ::core::ops::SubAssign<&'a X>

0 commit comments

Comments
 (0)