mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
clamp interval before fuzz_bounds (#3024)
* clamp interval before fuzz_bounds * update unit test of with_review_fuzz
This commit is contained in:
parent
68b374e65f
commit
103ea6ded0
1 changed files with 3 additions and 2 deletions
|
@ -77,6 +77,7 @@ pub(crate) fn with_review_fuzz(
|
|||
/// it and it is larger than 1.
|
||||
fn constrained_fuzz_bounds(interval: f32, minimum: u32, maximum: u32) -> (u32, u32) {
|
||||
let minimum = minimum.min(maximum);
|
||||
let interval = interval.clamp(minimum as f32, maximum as f32);
|
||||
let (mut lower, mut upper) = fuzz_bounds(interval);
|
||||
|
||||
// minimum <= maximum and lower <= upper are assumed
|
||||
|
@ -164,8 +165,8 @@ mod test {
|
|||
assert_lower_middle_upper!(20.1, 3, 1000, 17, 20, 23);
|
||||
|
||||
// respect limits and preserve uniform distribution of valid intervals
|
||||
assert_lower_middle_upper!(100.0, 101, 1000, 101, 104, 107);
|
||||
assert_lower_middle_upper!(100.0, 1, 99, 93, 96, 99);
|
||||
assert_lower_middle_upper!(100.0, 101, 1000, 101, 105, 108);
|
||||
assert_lower_middle_upper!(100.0, 1, 99, 92, 96, 99);
|
||||
assert_lower_middle_upper!(100.0, 97, 103, 97, 100, 103);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue