Skip to content

Commit 9695bad

Browse files
committed
Fix clippy and lints
1 parent 95c395b commit 9695bad

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pallets/subtensor/src/tests/epoch.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,19 +2285,19 @@ fn test_compute_alpha_values() {
22852285
// exp_val = exp(0.0 - 1.0 * 0.1) = exp(-0.1)
22862286
// alpha[0] = 1 / (1 + exp(-0.1)) ~ 0.9048374180359595
22872287
let exp_val_0 = I32F32::from_num(0.9048374180359595);
2288-
let expected_alpha_0 = I32F32::from_num(1.0) / I32F32::from_num(1.0).saturating_add(exp_val_0);
2288+
let expected_alpha_0 = I32F32::from_num(1.0) / (I32F32::from_num(1.0) + exp_val_0);
22892289

22902290
// For consensus[1] = 0.5:
22912291
// exp_val = exp(0.0 - 1.0 * 0.5) = exp(-0.5)
22922292
// alpha[1] = 1 / (1 + exp(-0.5)) ~ 0.6065306597126334
22932293
let exp_val_1 = I32F32::from_num(0.6065306597126334);
2294-
let expected_alpha_1 = I32F32::from_num(1.0) / I32F32::from_num(1.0).saturating_add(exp_val_1);
2294+
let expected_alpha_1 = I32F32::from_num(1.0) / (I32F32::from_num(1.0) + exp_val_1);
22952295

22962296
// For consensus[2] = 0.9:
22972297
// exp_val = exp(0.0 - 1.0 * 0.9) = exp(-0.9)
22982298
// alpha[2] = 1 / (1 + exp(-0.9)) ~ 0.4065696597405991
22992299
let exp_val_2 = I32F32::from_num(0.4065696597405991);
2300-
let expected_alpha_2 = I32F32::from_num(1.0) / I32F32::from_num(1.0).saturating_add(exp_val_2);
2300+
let expected_alpha_2 = I32F32::from_num(1.0) / (I32F32::from_num(1.0) + exp_val_2);
23012301

23022302
// Define an epsilon for approximate equality checks.
23032303
let epsilon = I32F32::from_num(1e-6);
@@ -2329,13 +2329,13 @@ fn test_compute_alpha_values_256_miners() {
23292329

23302330
for (i, &c) in consensus.iter().enumerate() {
23312331
// Use saturating subtraction and multiplication
2332-
let exponent = b.saturating_sub(a.saturating_mul(c));
2332+
let exponent = b - (a * c);
23332333

23342334
// Use safe_exp instead of exp
23352335
let exp_val = safe_exp(exponent);
23362336

23372337
// Use saturating addition and division
2338-
let expected_alpha = I32F32::from_num(1.0) / I32F32::from_num(1.0).saturating_add(exp_val);
2338+
let expected_alpha = I32F32::from_num(1.0) / (I32F32::from_num(1.0) + exp_val);
23392339

23402340
// Assert that the computed alpha values match the expected values within the epsilon.
23412341
assert_approx_eq(alpha[i], expected_alpha, epsilon);

support/linting/src/forbid_saturating_math.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn is_saturating_math_call(func: &Expr) -> bool {
5050
return false;
5151
};
5252

53-
path.last().map_or(false, |seg| {
53+
path.last().is_some_and(|seg| {
5454
seg.ident.to_string().starts_with("saturating_")
5555
})
5656
}

0 commit comments

Comments
 (0)