From 700222bf97d168d0a879de032f107f61f6d7d0b5 Mon Sep 17 00:00:00 2001 From: Dev Null Date: Wed, 8 May 2024 15:44:41 +0800 Subject: [PATCH] fix linter issues --- src/cli.rs | 48 ++++++++++++++++++++++---------------------- src/corrections.rs | 4 ++-- src/preprocessing.rs | 9 ++++----- src/test_common.rs | 4 ++-- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 0ffc1e2..a5fa41c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -858,12 +858,12 @@ impl<'a> BirliContext<'a> { } // filter vis_sel.baseline_idxs that correspond with antennas not in antenna_idxs vis_sel.baseline_idxs.retain(|idx| { - let (ant1, ant2) = ( - corr_ctx.metafits_context.baselines[*idx].ant1_index, - corr_ctx.metafits_context.baselines[*idx].ant2_index, - ); - antenna_idxs.contains(&ant1) && antenna_idxs.contains(&ant2) - }); + let (ant1, ant2) = ( + corr_ctx.metafits_context.baselines[*idx].ant1_index, + corr_ctx.metafits_context.baselines[*idx].ant2_index, + ); + antenna_idxs.contains(&ant1) && antenna_idxs.contains(&ant2) + }); } Err(err) => match err.kind() { ArgumentNotFound { .. } => {} @@ -1874,7 +1874,7 @@ mod tests { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(!birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -2884,7 +2884,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(!birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -2989,7 +2989,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3070,7 +3070,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!(birli_ctx.prep_ctx.phase_centre, RADec { ra: 0., dec: 0. }); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), @@ -3155,7 +3155,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!(birli_ctx.prep_ctx.phase_centre, pointing_centre); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), @@ -3239,7 +3239,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(!birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, None)); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_none()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3294,7 +3294,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(!birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, None)); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_none()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3376,7 +3376,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(birli_ctx.prep_ctx.correct_digital_gains); assert!(!birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, None)); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_none()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3465,10 +3465,10 @@ mod tests_aoflagger { let birli_ctx = BirliContext::from_args(&args).unwrap(); assert!(!birli_ctx.prep_ctx.correct_cable_lengths); - assert!(matches!(birli_ctx.prep_ctx.passband_gains, Some(_))); + assert!(birli_ctx.prep_ctx.passband_gains.is_some()); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(!birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, None)); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_none()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3549,7 +3549,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3650,7 +3650,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(!birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3710,7 +3710,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(!birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3772,7 +3772,7 @@ mod tests_aoflagger { assert_eq!(birli_ctx.prep_ctx.passband_gains, None); assert!(!birli_ctx.prep_ctx.correct_digital_gains); assert!(!birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3887,10 +3887,10 @@ mod tests_aoflagger_flagset { let birli_ctx = BirliContext::from_args(&args).unwrap(); assert!(birli_ctx.prep_ctx.correct_cable_lengths); - assert!(matches!(birli_ctx.prep_ctx.passband_gains, None)); + assert!(birli_ctx.prep_ctx.passband_gains.is_none()); assert!(birli_ctx.prep_ctx.correct_digital_gains); assert!(birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path @@ -3986,10 +3986,10 @@ mod tests_aoflagger_flagset { let birli_ctx = BirliContext::from_args(&args).unwrap(); assert!(birli_ctx.prep_ctx.correct_cable_lengths); - assert!(matches!(birli_ctx.prep_ctx.passband_gains, None)); + assert!(birli_ctx.prep_ctx.passband_gains.is_none()); assert!(birli_ctx.prep_ctx.correct_digital_gains); assert!(birli_ctx.prep_ctx.correct_geometry); - assert!(matches!(birli_ctx.prep_ctx.aoflagger_strategy, Some(_))); + assert!(birli_ctx.prep_ctx.aoflagger_strategy.is_some()); assert_eq!( birli_ctx.io_ctx.metafits_in.display().to_string(), metafits_path diff --git a/src/corrections.rs b/src/corrections.rs index 73e16ef..1de9593 100644 --- a/src/corrections.rs +++ b/src/corrections.rs @@ -123,7 +123,7 @@ pub fn correct_cable_lengths( for (mut jones_array, &freq_hz) in jones_array.axis_iter_mut(Axis(1)).zip_eq(&all_freqs_hz) { - for jones in jones_array.iter_mut() { + for jones in &mut jones_array { // promote, correct, demote let mut corrected = Jones::::from(*jones); for (complex, length) in corrected.iter_mut().zip_eq(&pol_lengths) { @@ -414,7 +414,7 @@ fn _correct_digital_gains( gains.index_axis(Axis(0), ant2_idx), ) { // for all visibilities in the selected coarse channel, for all timesteps - for jones in jones_array.iter_mut() { + for jones in &mut jones_array { // promote, correct, demote let mut corrected = Jones::::from(*jones); corrected[0] /= gain1x * gain2x; diff --git a/src/preprocessing.rs b/src/preprocessing.rs index e870bd1..3c43a00 100644 --- a/src/preprocessing.rs +++ b/src/preprocessing.rs @@ -413,16 +413,15 @@ mod tests { corr_ctx.metafits_context.mwa_version = Some(MWAVersion::CorrOldLegacy); - assert!(matches!( - prep_ctx.preprocess( + assert!(prep_ctx + .preprocess( &corr_ctx, jones_array.view_mut(), weight_array.view_mut(), flag_array.view_mut(), &vis_sel, - ), - Ok(_) - )); + ) + .is_ok()); corr_ctx.metafits_context.mwa_version = Some(MWAVersion::VCSLegacyRecombined); diff --git a/src/test_common.rs b/src/test_common.rs index b6477b3..823de93 100644 --- a/src/test_common.rs +++ b/src/test_common.rs @@ -235,7 +235,7 @@ pub fn compare_uvfits_with_csv( let mut obs_vis: Vec = vec![0.0; vis_len]; let mut obs_group_params: Vec = vec![0.0; pcount]; - let pol_order = vec!["xx", "yy", "xy", "yx"]; + let pol_order = ["xx", "yy", "xy", "yx"]; assert_eq!(num_pols, pol_order.len()); let time_resolution = 1. / 1_000_000.; @@ -485,7 +485,7 @@ pub fn compare_ms_with_csv( let mut row_idx = 0; let mut mjds_seen = HashSet::::new(); - let pol_order = vec!["xx", "xy", "yx", "yy"]; + let pol_order = ["xx", "xy", "yx", "yy"]; assert_eq!(num_pols, pol_order.len()); for record in expected_reader.records().map(std::result::Result::unwrap) {