Skip to content

Commit

Permalink
clippy --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
asukaminato0721 committed Dec 19, 2023
1 parent a71c5ac commit dfc89fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ mod tests {
let metrics = fsrs.evaluate(items.clone(), |_| true).unwrap();

Data::from([metrics.log_loss, metrics.rmse_bins])
.assert_approx_eq(&Data::from([0.21364396810531616, 0.05370686203241348]), 5);
.assert_approx_eq(&Data::from([0.213_643_97, 0.053_706_862]), 5);

let fsrs = FSRS::new(Some(WEIGHTS))?;
let metrics = fsrs.evaluate(items, |_| true).unwrap();
Expand Down
36 changes: 18 additions & 18 deletions src/pre_training.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,22 @@ fn smooth_and_fill(
init_s0.sort_by(|a, b| a.partial_cmp(b).unwrap());
}
2 => {
match (rating_stability_arr) {
([None, None, Some(&r3), Some(&r4)]) => {
match rating_stability_arr {
[None, None, Some(&r3), Some(&r4)] => {
let r2 = r3.powf(1.0 / (1.0 - w2)) * r4.powf(1.0 - 1.0 / (1.0 - w2));
rating_stability.insert(2, r2);
rating_stability.insert(1, (r2.powf(1.0 / w1)) * (r3.powf(1.0 - 1.0 / w1)));
}
([None, Some(&r2), None, Some(&r4)]) => {
[None, Some(&r2), None, Some(&r4)] => {
let r3 = r2.powf(1.0 - w2) * r4.powf(w2);
rating_stability.insert(3, r3);
rating_stability.insert(1, r2.powf(1.0 / w1) * r3.powf(1.0 - 1.0 / w1));
}
([None, Some(&r2), Some(&r3), None]) => {
[None, Some(&r2), Some(&r3), None] => {
rating_stability.insert(4, r2.powf(1.0 - 1.0 / w2) * r3.powf(1.0 / w2));
rating_stability.insert(1, r2.powf(1.0 / w1) * r3.powf(1.0 - 1.0 / w1));
}
([Some(&r1), None, None, Some(&r4)]) => {
[Some(&r1), None, None, Some(&r4)] => {
let r2 = r1.powf(w1 / (w1.mul_add(-w2, w1 + w2)))
* r4.powf(1.0 - w1 / (w1.mul_add(-w2, w1 + w2)));
rating_stability.insert(2, r2);
Expand All @@ -240,12 +240,12 @@ fn smooth_and_fill(
* r4.powf(w2 / (w1.mul_add(-w2, w1 + w2))),
);
}
([Some(&r1), None, Some(&r3), None]) => {
[Some(&r1), None, Some(&r3), None] => {
let r2 = r1.powf(w1) * r3.powf(1.0 - w1);
rating_stability.insert(2, r2);
rating_stability.insert(4, r2.powf(1.0 - 1.0 / w2) * r3.powf(1.0 / w2));
}
([Some(&r1), Some(&r2), None, None]) => {
[Some(&r1), Some(&r2), None, None] => {
let r3 = r1.powf(1.0 - 1.0 / (1.0 - w1)) * r2.powf(1.0 / (1.0 - w1));
rating_stability.insert(3, r3);
rating_stability.insert(4, r2.powf(1.0 - 1.0 / w2) * r3.powf(1.0 / w2));
Expand All @@ -259,17 +259,17 @@ fn smooth_and_fill(
.collect();
}
3 => {
match (rating_stability_arr) {
([None, Some(r2), Some(r3), _]) => {
match rating_stability_arr {
[None, Some(r2), Some(r3), _] => {
rating_stability.insert(1, r2.powf(1.0 / w1) * r3.powf(1.0 - 1.0 / w1));
}
([Some(r1), None, Some(r3), _]) => {
[Some(r1), None, Some(r3), _] => {
rating_stability.insert(2, r1.powf(w1) * r3.powf(1.0 - w1));
}
([_, Some(r2), None, Some(r4)]) => {
[_, Some(r2), None, Some(r4)] => {
rating_stability.insert(3, r2.powf(1.0 - w2) * r4.powf(w2));
}
([_, Some(r2), Some(r3), None]) => {
[_, Some(r2), Some(r3), None] => {
rating_stability.insert(4, r2.powf(1.0 - 1.0 / w2) * r3.powf(1.0 / w2));
}
_ => {}
Expand Down Expand Up @@ -353,8 +353,8 @@ mod tests {
],
)]);
let actual = search_parameters(pretrainset, 0.9);
Data::from([actual.get(&4).unwrap().clone()])
.assert_approx_eq(&Data::from([1.2301323413848877]), 4);
Data::from([*actual.get(&4).unwrap()])
.assert_approx_eq(&Data::from([1.230_132_3]), 4);
}

#[test]
Expand All @@ -365,10 +365,10 @@ mod tests {
let pretrainset = split_data(items, 1).0;
Data::from(pretrain(pretrainset, average_recall).unwrap()).assert_approx_eq(
&Data::from([
0.9560174345970154,
1.694406509399414,
3.998023509979248,
8.26822280883789,
0.956_017_43,
1.694_406_5,
3.998_023_5,
8.268_223,
]),
4,
)
Expand Down

0 comments on commit dfc89fe

Please sign in to comment.