Skip to content

Commit

Permalink
Fix/sort init_s0 on generating from r_s0_default
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Dec 19, 2023
1 parent 4a9ca4d commit 9c776c4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pre_training.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ fn smooth_and_fill(
let rating = rating_stability.keys().next().unwrap();
let factor = rating_stability[rating] / r_s0_default[rating];
init_s0 = r_s0_default.values().map(|&x| x * factor).collect();
init_s0.sort_by(|a, b| a.partial_cmp(b).unwrap());
}
2 => {
match (
Expand Down Expand Up @@ -384,5 +385,10 @@ mod tests {
let rating_count = HashMap::from([(1, 1), (2, 1), (3, 1), (4, 1)]);
let actual = smooth_and_fill(&mut rating_stability, &rating_count).unwrap();
assert_eq!(actual, [0.4, 0.8052433, 2.3, 10.9,]);

let mut rating_stability = HashMap::from([(2, 0.35)]);
let rating_count = HashMap::from([(2, 1)]);
let actual = smooth_and_fill(&mut rating_stability, &rating_count).unwrap();
assert_eq!(actual, [0.1277027, 0.35, 0.6148648, 2.6108108,]);
}
}

0 comments on commit 9c776c4

Please sign in to comment.