Skip to content

Commit fe1b08d

Browse files
committed
fix: clippy
1 parent 55344a5 commit fe1b08d

15 files changed

Lines changed: 23 additions & 34 deletions

File tree

examples/rl_vs_classical_fbm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn timing_table() -> Vec<TimingPoint> {
6363
for &n in &sizes {
6464
let classical = Fbm::<f64>::new(h, n, Some(1.0));
6565
let rl = RlFBm::<f64>::new(h, n, Some(1.0), None);
66-
let iters = (5_000_000 / n).max(40).min(2_000);
66+
let iters = (5_000_000 / n).clamp(40, 2_000);
6767
let t_classical = bench_time(|| classical.sample(), iters);
6868
let t_rl = bench_time(|| rl.sample(), iters);
6969
let ratio = t_rl / t_classical;

stochastic-rs-quant/src/calibration/rbergomi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ mod tests {
10561056
xi0: RBergomiXi0::Constant(0.04),
10571057
};
10581058

1059-
let maturities = vec![0.25, 0.5, 1.0];
1059+
let maturities = [0.25, 0.5, 1.0];
10601060
let mut market_slices = Vec::with_capacity(maturities.len());
10611061
for (i, &t) in maturities.iter().enumerate() {
10621062
let market_samples = simulate_rbergomi_terminal_samples(

stochastic-rs-quant/src/curves/bootstrap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,6 @@ mod tests {
256256
},
257257
];
258258
let curve = bootstrap_iterative(&inst, InterpolationMethod::LinearOnZeroRates, 1e-10, 50);
259-
assert!(curve.len() >= 1);
259+
assert!(!curve.is_empty());
260260
}
261261
}

stochastic-rs-quant/src/pricing/rainbow.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@ impl McRainbowPricer {
297297

298298
#[cfg(test)]
299299
mod tests {
300-
use ndarray::array;
301-
302300
use super::*;
303301

304302
/// Stulz: $C_{\min} + C_{\max} = C_1 + C_2$ (vanilla call sum).

stochastic-rs-quant/src/pricing/regime_switching.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ mod tests {
527527
q_mat[[0, 0]] = Complex64::new(-0.5 * t, 0.0);
528528
q_mat[[0, 1]] = Complex64::new(0.5 * t, 0.0);
529529
q_mat[[1, 0]] = Complex64::new(1.0 * t, 0.0);
530-
q_mat[[1, 1]] = Complex64::new(-1.0 * t, 0.0);
530+
q_mat[[1, 1]] = Complex64::new(-t, 0.0);
531531
let result = matrix_exp_complex(&q_mat);
532532

533533
for i in 0..2 {

stochastic-rs-quant/src/pricing/sabr.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,16 +481,7 @@ mod tests {
481481
// β=1 OTM put
482482
(90.0, 100.0, 1.0, 0.2, 1.0, -0.3, 0.5, 2.118933616456034e-01),
483483
// β=0.5 ATM
484-
(
485-
100.0,
486-
100.0,
487-
0.5,
488-
0.15,
489-
0.5,
490-
-0.2,
491-
0.8,
492-
1.537376757812500e-02,
493-
),
484+
(100.0, 100.0, 0.5, 0.15, 0.5, -0.2, 0.8, 1.5373767578125e-02),
494485
// β=0.5 OTM call
495486
(
496487
110.0,
@@ -582,7 +573,7 @@ mod tests {
582573
1.401312256794535e-01,
583574
),
584575
// β=0.7 long-dated
585-
(0.30, 50.0, 2.0, 0.7, 0.1, 0.4, 9.409442654142710e-01),
576+
(0.30, 50.0, 2.0, 0.7, 0.1, 0.4, 9.40944265414271e-01),
586577
// β=0 (normal Sabr)
587578
(0.25, 100.0, 1.0, 0.0, 0.0, 0.3, 2.475118650781591e+01),
588579
];

stochastic-rs-quant/src/pricing/snell_envelope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ mod tests {
411411
assert!(!result.exercise_boundary.is_empty());
412412

413413
for &(t, s_star) in &result.exercise_boundary {
414-
assert!(t >= 0.0 && t < 1.0);
414+
assert!((0.0..1.0).contains(&t));
415415
assert!(s_star > 0.0 && s_star <= 100.0);
416416
}
417417

stochastic-rs-stats/src/leverage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ mod tests {
9898
}
9999
let closes = Array1::from_vec(vals);
100100
let rho = estimate_leverage_rho(closes.view());
101-
assert!(rho >= -0.99 && rho <= 0.99, "rho out of range: {rho}");
101+
assert!((-0.99..=0.99).contains(&rho), "rho out of range: {rho}");
102102
}
103103
}

stochastic-rs-stats/src/mle/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ mod tests {
264264
let cir = Cir::seeded(3.0, 0.3, 0.2, 100, Some(0.4), Some(1.0), None, 0);
265265
let dt = 1.0 / 250.0;
266266
let d = DensityApprox::Euler.density(&cir, 0.4, 0.41, 0.0, dt);
267-
// reference value: 18.715933204468332
267+
// reference value: 18.71593320446833
268268
assert!(
269-
(d - 18.715933204468332).abs() < 1e-8,
270-
"Cir Euler: got {d}, expected 18.715933204468332"
269+
(d - 18.71593320446833).abs() < 1e-8,
270+
"Cir Euler: got {d}, expected 18.71593320446833"
271271
);
272272
}
273273

stochastic-rs-stats/src/tail_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ mod tests {
184184
let m = data.sum() / data.len() as f64;
185185
let v = data.iter().map(|x| (x - m).powi(2)).sum::<f64>() / (data.len() - 1) as f64;
186186
let alpha = estimate_cgmy_alpha(data.view(), m, v);
187-
assert!(alpha >= 0.1 && alpha <= 1.9, "alpha out of range: {alpha}");
187+
assert!((0.1..=1.9).contains(&alpha), "alpha out of range: {alpha}");
188188
}
189189

190190
#[test]

0 commit comments

Comments
 (0)