Skip to content

Commit 361c9f7

Browse files
committed
formatting new clippy version
1 parent e1c20c1 commit 361c9f7

8 files changed

Lines changed: 51 additions & 63 deletions

File tree

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn main() {
1313
.to_string();
1414
let make_args: Vec<String> = vec![
1515
"-j8".to_string(),
16-
format!("BUILD_DIR={}", slicot_build_dir).to_string(),
16+
format!("BUILD_DIR={slicot_build_dir}").to_string(),
1717
];
1818

1919
let status = make()
@@ -32,7 +32,7 @@ fn main() {
3232
panic!("Failed to build SLICOT")
3333
}
3434

35-
println!("cargo:rustc-link-search={}", slicot_build_dir);
35+
println!("cargo:rustc-link-search={slicot_build_dir}");
3636
println!("cargo:rustc-link-lib=static=slicot");
3737
println!("cargo:rustc-link-lib=static=lpkaux");
3838
println!("cargo:rustc-link-lib=gfortran");

src/analysis/frequency_response.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ fn freq_response_ss_mat(
254254

255255
if info != 0 {
256256
return Err(format!(
257-
"Failed to compute frequency response of state space system. Slicot TB05AD failed with error code: {}",
258-
info
257+
"Failed to compute frequency response of state space system. Slicot TB05AD failed with error code: {info}"
259258
));
260259
}
261260

src/analysis/system_properties.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,11 @@ fn h2_norm<U: Time + 'static>(
104104

105105
if info != 0 {
106106
return Err(Box::new(std::io::Error::other(format!(
107-
"SLICOT ab13bd failed with the follwing error indicator: {}",
108-
info
107+
"SLICOT ab13bd failed with the follwing error indicator: {info}"
109108
))));
110109
} else if iwarn != 0 {
111110
return Err(Box::new(std::io::Error::other(format!(
112-
"SLICOT ab13bd returned with warning about numerical stability. Iwarn = {}",
113-
iwarn
111+
"SLICOT ab13bd returned with warning about numerical stability. Iwarn = {iwarn}"
114112
))));
115113
}
116114

@@ -222,8 +220,7 @@ fn hinf_norm<U: Time + 'static>(
222220

223221
if info != 0 {
224222
return Err(format!(
225-
"SLICOT ab13dd returned with error code. info = {}",
226-
info
223+
"SLICOT ab13dd returned with error code. info = {info}"
227224
));
228225
}
229226

@@ -316,8 +313,7 @@ pub fn zeros(
316313

317314
if info != 0 {
318315
return Err(format!(
319-
"SLICOT failed to find zeros of state-space system. Info = {}",
320-
info
316+
"SLICOT failed to find zeros of state-space system. Info = {info}"
321317
));
322318
}
323319
let ldwork = dwork[0] as usize;
@@ -359,8 +355,7 @@ pub fn zeros(
359355

360356
if info != 0 {
361357
return Err(format!(
362-
"SLICOT failed to find zeros of state-space system. Info = {}",
363-
info
358+
"SLICOT failed to find zeros of state-space system. Info = {info}"
364359
));
365360
}
366361
if num_inv_zeros == 0 {
@@ -407,7 +402,7 @@ pub fn zeros(
407402
);
408403
}
409404
if info != 0 {
410-
return Err(format!("LAPACK DGGEV returned info = {}", info));
405+
return Err(format!("LAPACK DGGEV returned info = {info}"));
411406
}
412407
lwork = dwork[0] as c_int;
413408
assert!(lwork > 0);
@@ -436,7 +431,7 @@ pub fn zeros(
436431
);
437432
}
438433
if info != 0 {
439-
return Err(format!("LAPACK DGGEV returned info = {}", info));
434+
return Err(format!("LAPACK DGGEV returned info = {info}"));
440435
}
441436

442437
let mut zeros = Vec::with_capacity(n_gen_eigen);
@@ -624,9 +619,9 @@ mod tests {
624619
#[test]
625620
fn ss_zeros() {
626621
let tf = (Tf::s() - 1.0) * (Tf::s() + 4.0) / (Tf::s() + 2.0).powi(2);
627-
println!("tf: \n{}", tf);
622+
println!("tf: \n{tf}");
628623
let zeros = tf.to_ss_method(ControllableCF).unwrap().zeros().unwrap();
629-
println!("zeros: {:?}", zeros);
624+
println!("zeros: {zeros:?}");
630625
assert_eq!(zeros.len(), 2);
631626

632627
let tf = 1.0 / Tf::s();
@@ -675,18 +670,18 @@ mod tests {
675670
#[test]
676671
fn ss_is_stable() {
677672
let tf = 1.0 / Tf::s();
678-
assert_eq!(tf.to_ss_method(ObservableCF).unwrap().is_stable(), false);
673+
assert!(!tf.to_ss_method(ObservableCF).unwrap().is_stable());
679674

680675
let tf = (Tf::s() + 1.0) / (Tf::s() + 1.0).powi(4);
681676
let ss = tf.to_ss_method(ObservableCF).unwrap();
682-
assert_eq!(ss.is_stable(), true);
677+
assert!(ss.is_stable());
683678

684679
let tf = 1.0 / ((Tf::s() + 1.0) * (Tf::s() - 2.0));
685680
let ss = tf.to_ss_method(ObservableCF).unwrap();
686-
assert_eq!(ss.is_stable(), false);
681+
assert!(!ss.is_stable());
687682

688683
let tf = 1.0 / (Tf::s().powi(2) + 2.0 * 0.01 * Tf::s() + 1.0);
689684
let ss = tf.to_ss_method(ObservableCF).unwrap();
690-
assert_eq!(ss.is_stable(), true);
685+
assert!(ss.is_stable());
691686
}
692687
}

src/systems/polynom.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ where
6060

6161
let term_i = match exp {
6262
0 => val.to_string(),
63-
1 => format!("{}{}", val, var_name),
64-
_ => format!("{}{}^{}", val, var_name, exp),
63+
1 => format!("{val}{var_name}"),
64+
_ => format!("{val}{var_name}^{exp}"),
6565
};
6666
terms.push(term_i);
6767
}
@@ -76,7 +76,7 @@ where
7676
{
7777
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7878
let str_poly = self.to_string_variable("x");
79-
write!(f, "{}", str_poly)
79+
write!(f, "{str_poly}")
8080
}
8181
}
8282

@@ -353,11 +353,7 @@ where
353353
assert!(num_str.len() <= max_len);
354354
assert!(den_str.len() <= max_len);
355355

356-
write!(
357-
formatter,
358-
"\n {}\n {}\n {}\n\n",
359-
num_str, dash_line, den_str
360-
)
356+
write!(formatter, "\n {num_str}\n {dash_line}\n {den_str}\n\n")
361357
}
362358
}
363359

@@ -649,7 +645,7 @@ mod tests {
649645
lhs_vals
650646
.iter()
651647
.zip(rhs_vals.iter())
652-
.all(|(x, y)| f64::abs_diff_eq(&x, &y, epsilon))
648+
.all(|(x, y)| f64::abs_diff_eq(x, y, epsilon))
653649
}
654650
}
655651

@@ -712,9 +708,9 @@ mod tests {
712708
}
713709

714710
{
715-
println!("poly: {}", p);
711+
println!("poly: {p}");
716712
let p_str = p.to_string();
717-
println!("poly to string: {}", p_str);
713+
println!("poly to string: {p_str}");
718714
}
719715
}
720716

@@ -760,7 +756,7 @@ mod tests {
760756
assert_abs_diff_eq!(rf.num.coeffs[0], 1.0);
761757
assert_abs_diff_eq!(rf.num.coeffs.last().unwrap().clone(), 3.0);
762758

763-
println!("Rational function normalize: \n{}", rf);
759+
println!("Rational function normalize: \n{rf}");
764760
}
765761

766762
#[test]

src/systems/state_space.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ impl<U: Time + 'static> fmt::Display for Ss<U> {
612612
} else {
613613
"Unknown"
614614
};
615-
write!(f, "{}-time state-space model\n\n", time_domain)
615+
write!(f, "{time_domain}-time state-space model\n\n")
616616
}
617617
}
618618

@@ -635,7 +635,7 @@ mod tests {
635635
rng: &mut U,
636636
max_order: usize,
637637
) -> Tf<f64, Continuous> {
638-
let den_order = rng.random_range(1..=max_order) as usize;
638+
let den_order = rng.random_range(1..=max_order);
639639
let num_order = rng.random_range(0..=den_order);
640640

641641
let num: Vec<f64> = (0..=num_order)
@@ -884,14 +884,14 @@ mod tests {
884884
#[test]
885885
fn ss_display() {
886886
let sys = (1.0 / Tf::s()).to_ss().unwrap();
887-
println!("1: {}", sys);
887+
println!("1: {sys}");
888888

889889
let sys = Ss::<Discrete>::new_from_scalar(2.0);
890-
println!("2: {}", sys);
890+
println!("2: {sys}");
891891

892892
let sys = ((1.0 + Tf::s()) / ((Tf::s() - 1.0) * Tf::s()).powi(2))
893893
.to_ss()
894894
.unwrap();
895-
println!("3: {}after", sys);
895+
println!("3: {sys}after");
896896
}
897897
}

src/systems/transfer_function.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,10 @@ mod tests {
497497
assert_abs_diff_eq!(y.re, y_expect.re);
498498
assert_abs_diff_eq!(y.im, y_expect.im);
499499
}
500-
println!("Tf cont: \n{}", tf);
500+
println!("Tf cont: \n{tf}");
501501

502502
let tf_z = Tf::<f64, Discrete>::new_from_rf(tf.rf);
503-
println!("Tf discrete: \n {}", tf_z);
503+
println!("Tf discrete: \n {tf_z}");
504504
}
505505

506506
#[test]
@@ -553,16 +553,16 @@ mod tests {
553553
Tf::<f64, Discrete>::new(&[0.0, 0., 0., 1., 2., 0.0], &[0.0, 1.]);
554554
assert_eq!(sys.degree_num_den(), (4, 1));
555555
assert_eq!(sys.relative_degree(), 4 - 1);
556-
assert_eq!(sys.is_proper(), false);
557-
assert_eq!(sys.is_strictly_proper(), false);
556+
assert!(!sys.is_proper());
557+
assert!(!sys.is_strictly_proper());
558558

559559
let sys = Tf::s() / Tf::s();
560-
assert_eq!(sys.is_proper(), true);
561-
assert_eq!(sys.is_strictly_proper(), false);
560+
assert!(sys.is_proper());
561+
assert!(!sys.is_strictly_proper());
562562

563563
let sys = 1. / Tf::s();
564-
assert_eq!(sys.is_proper(), true);
565-
assert_eq!(sys.is_strictly_proper(), true);
564+
assert!(sys.is_proper());
565+
assert!(sys.is_strictly_proper());
566566
}
567567

568568
#[test]
@@ -582,11 +582,11 @@ mod tests {
582582
#[test]
583583
fn tf_display() {
584584
let tf = 1.0 / Tf::s();
585-
println!("1: {}", tf);
585+
println!("1: {tf}");
586586
let tf = 1.0 / Tf::s().powi(5) * (Tf::s() + 1.0);
587-
println!("2: {}", tf);
587+
println!("2: {tf}");
588588
let tf =
589589
2.1 / Tf::s() * (Tf::s() - 1.2).powi(5) / (Tf::s() + 1.0).powi(3);
590-
println!("3: {}", tf);
590+
println!("3: {tf}");
591591
}
592592
}

src/transformations.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ fn ss2tf_mat<U: Time + 'static>(
119119

120120
if info != 0 {
121121
return Err(Box::new(std::io::Error::other(format!(
122-
"SLICOT tb04ad_ failed with info code {}",
123-
info
122+
"SLICOT tb04ad_ failed with info code {info}"
124123
))));
125124
}
126125

@@ -402,8 +401,7 @@ pub fn minreal_mat_mut(
402401

403402
if info != 0 {
404403
return Err(format!(
405-
"Minreal failed. SLICOT TB01PD returned info = {}",
406-
info
404+
"Minreal failed. SLICOT TB01PD returned info = {info}"
407405
));
408406
}
409407

@@ -591,7 +589,7 @@ mod tests {
591589
rng: &mut U,
592590
max_order: usize,
593591
) -> Tf<f64, Continuous> {
594-
let den_order = rng.random_range(1..=max_order) as usize;
592+
let den_order = rng.random_range(1..=max_order);
595593
let num_order = rng.random_range(0..=den_order);
596594

597595
let num: Vec<f64> = (0..=num_order)
@@ -644,7 +642,7 @@ mod tests {
644642
let tf = ss.to_tf().unwrap();
645643

646644
let tf_ans = 1. / Tf::s().powi(2);
647-
println!("ss2Tf: \n{}", tf);
645+
println!("ss2Tf: \n{tf}");
648646
assert_abs_diff_eq!(tf, tf_ans);
649647
}
650648

@@ -670,8 +668,8 @@ mod tests {
670668
assert_eq!(ss.order(), 0);
671669
assert_eq!(ss.d()[(0, 0)], 1.0);
672670

673-
assert_eq!(tf.is_strictly_proper(), false);
674-
assert_eq!(tf.is_proper(), true);
671+
assert!(!tf.is_strictly_proper());
672+
assert!(tf.is_proper());
675673
}
676674

677675
#[test]
@@ -708,7 +706,7 @@ mod tests {
708706
let ss = tf.to_ss().unwrap();
709707
println!("a: {}, b: {}, c: {}, d: {}", ss.a(), ss.b(), ss.c(), ss.d());
710708
let tf_minreal = ss.minreal(None).unwrap().to_tf().unwrap();
711-
println!("tf minreal:\n{}", tf_minreal);
709+
println!("tf minreal:\n{tf_minreal}");
712710
assert_abs_diff_eq!(1.0 / Tf::s(), tf_minreal, epsilon = 1e-2);
713711

714712
let tf = Tf::s().powi(5) / Tf::s().powi(6);

src/utils/traits.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ mod tests {
196196

197197
#[test]
198198
fn mag_db_covert() {
199-
assert_abs_diff_eq!((1. as f64).mag2db(), 0.);
200-
assert_abs_diff_eq!((1. as f32).mag2db(), 0.);
199+
assert_abs_diff_eq!(1_f64.mag2db(), 0.);
200+
assert_abs_diff_eq!(1_f32.mag2db(), 0.);
201201

202-
assert_abs_diff_eq!((20 as f64).db2mag(), 10.);
203-
assert_abs_diff_eq!((20 as f32).db2mag(), 10.);
202+
assert_abs_diff_eq!(20_f64.db2mag(), 10.);
203+
assert_abs_diff_eq!(20_f32.db2mag(), 10.);
204204

205205
let mut rng = rand::rng();
206206

0 commit comments

Comments
 (0)