Skip to content

Commit

Permalink
fix linter issues, downgrade vec1 for msrv compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
d3v-null committed Jul 4, 2024
1 parent 8762cf9 commit ff2f29a
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 48 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
"Dev Null <[email protected]>",
]
edition = "2021"
rust-version = "1.68"
rust-version = "1.68" # `cargo +1.68 build --locked` works, but technically development needs 1.73
license = "MPL-2.0"
readme = "README.md"
description = "Calibration software for the Murchison Widefield Array (MWA) radio telescope"
Expand Down Expand Up @@ -96,7 +96,8 @@ strum = "0.24.0"
strum_macros = "0.24.0"
thiserror = "1.0.7"
toml = "0.7.2"
vec1 = { version = "1.5.0", features = ["serde"] }
# TODO: bump vec1 after msrv update
vec1 = { version = "~1.10.0", features = ["serde"] }

# "cuda" feature
cuda-runtime-sys = { version = "0.3.0-alpha.1", optional = true }
Expand All @@ -114,7 +115,7 @@ plotters = { version = "0.3.5", default-features = false, features = [

[dev-dependencies]
approx = "0.5.1"
assert_cmd = "2.0.0"
assert_cmd = "2.0.0" # 2.0.14 requires Rust 1.73.0
criterion = { version = "0.4.0", default_features = false }
indoc = "2.0.1"
marlu = { version = "0.11.0", features = ["approx"] }
Expand Down
3 changes: 0 additions & 3 deletions src/beam/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ use serial_test::serial;

use super::*;

#[cfg(any(feature = "cuda", feature = "hip"))]
use approx::abs_diff_eq;

#[test]
fn no_beam_means_no_beam() {
let azels = [
Expand Down
2 changes: 1 addition & 1 deletion src/cli/solutions/apply/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ fn test_solutions_apply_trivial(mut args: SolutionsApplyArgs) {
// Remove the newly-flagged chanblocks. (This is awkward because SPWs
// weren't designed to be modified.)
params.input_vis_params.spw.chanblocks = (0..)
.zip(params.input_vis_params.spw.chanblocks.into_iter())
.zip(params.input_vis_params.spw.chanblocks)
.filter(|(i, _)| !flagged_fine_chans.contains(i))
.map(|(_, c)| c)
.collect();
Expand Down
3 changes: 1 addition & 2 deletions src/cli/solutions/plot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,7 @@ mod plotting {
x_axis
.values()
.zip(amps.iter().map(|g| g[pol_index]))
.filter(|(_, y)| !y.is_nan())
.map(|(x, y)| (x, y)),
.filter(|(_, y)| !y.is_nan()),
1,
if [0, 3].contains(&pol_index) {
ShapeStyle::from(&colour).filled()
Expand Down
4 changes: 2 additions & 2 deletions src/flagging/mwaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ mod tests {
assert_eq!(s[6], 128);
assert_eq!(s[7], 3);

let expected = vec![
let expected = [
0.99999946,
0.99999946,
0.08406332,
Expand Down Expand Up @@ -670,7 +670,7 @@ mod tests {
assert_eq!(s[6], 128);
assert_eq!(s[7], 3);

let expected = vec![
let expected = [
0.99999946,
0.99999946,
0.08051342,
Expand Down
1 change: 1 addition & 0 deletions src/io/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub(crate) trait VisRead: Sync + Send {

/// Read auto-correlation visibilities for all frequencies and tiles in a
/// single timestep into the `data_array` and similar for the weights.
#[allow(dead_code)] // this is used in tests
fn read_autos(
&self,
vis_fb: ArrayViewMut2<Jones<f32>>,
Expand Down
4 changes: 2 additions & 2 deletions src/io/read/ms/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,12 @@ fn test_timestep_reading() {
let phase_centre = RADec::from_degrees(0., -27.);
let array_pos = LatLngHeight::mwa();
#[rustfmt::skip]
let tile_xyzs = vec![
let tile_xyzs = [
XyzGeodetic { x: 0., y: 0., z: 0., },
XyzGeodetic { x: 1., y: 0., z: 0., },
XyzGeodetic { x: 0., y: 1., z: 0., },
];
let tile_names = vec!["tile_0_0", "tile_1_0", "tile_0_1"];
let tile_names = ["tile_0_0", "tile_1_0", "tile_0_1"];

let marlu_obs_ctx = MarluObsContext {
sched_start_timestamp: Epoch::from_gpst_seconds(obsid as f64),
Expand Down
1 change: 1 addition & 0 deletions src/io/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ fn can_write_to_file_inner(file: &Path) -> Result<bool, FileWriteError> {
match std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(file)
.map_err(|e| e.kind())
{
Expand Down
15 changes: 6 additions & 9 deletions src/io/write/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,10 @@ fn test_vis_output_no_time_averaging_no_gaps() {
});

let result: Result<Result<(), VisWriteError>, _> = data_handle.join();
let result = match result {
match result {
Err(_) | Ok(Err(_)) => result.map(|_| Ok(String::new())),
Ok(Ok(())) => write_handle.join(),
};
result
}
});

match scoped_threads_result {
Expand Down Expand Up @@ -379,11 +378,10 @@ fn test_vis_output_no_time_averaging_with_gaps() {
});

let result: Result<Result<(), VisWriteError>, _> = data_handle.join();
let result = match result {
match result {
Err(_) | Ok(Err(_)) => result.map(|_| Ok(String::new())),
Ok(Ok(())) => write_handle.join(),
};
result
}
});

match scoped_threads_result {
Expand Down Expand Up @@ -586,11 +584,10 @@ fn test_vis_output_time_averaging() {
});

let result: Result<Result<(), VisWriteError>, _> = data_handle.join();
let result = match result {
match result {
Err(_) | Ok(Err(_)) => result.map(|_| Ok(String::new())),
Ok(Ok(())) => write_handle.join(),
};
result
}
});

match scoped_threads_result {
Expand Down
28 changes: 12 additions & 16 deletions src/math/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,21 @@ fn test_tile_baseline_flags_without_flags() {
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(0, 1)], 0);
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(0, 127)], 126);
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(126, 127)], 8127);
assert!(maps
assert!(!maps
.tile_to_unflagged_cross_baseline_map
.get(&(0, 0))
.is_none());
.contains_key(&(0, 0)));
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&0], (0, 1));
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&8127], (126, 127));
assert!(maps
assert!(!maps
.unflagged_cross_baseline_to_tile_map
.get(&8128)
.is_none());
.contains_key(&8128));

assert_eq!(maps.tile_to_unflagged_auto_index_map[&0], 0);
assert_eq!(maps.tile_to_unflagged_auto_index_map[&127], 127);
assert!(maps.tile_to_unflagged_auto_index_map.get(&128).is_none());
assert!(!maps.tile_to_unflagged_auto_index_map.contains_key(&128));
assert_eq!(maps.unflagged_auto_index_to_tile_map[&0], 0);
assert_eq!(maps.unflagged_auto_index_to_tile_map[&127], 127);
assert!(maps.unflagged_auto_index_to_tile_map.get(&128).is_none());
assert!(!maps.unflagged_auto_index_to_tile_map.contains_key(&128));

assert!(maps.flagged_tiles.is_empty());

Expand All @@ -84,24 +82,22 @@ fn test_tile_baseline_flags() {
let maps = TileBaselineFlags::new(total_num_tiles, tile_flags);
assert_eq!(maps.tile_to_unflagged_auto_index_map[&0], 0);
assert_eq!(maps.tile_to_unflagged_auto_index_map[&2], 1);
assert!(maps.tile_to_unflagged_auto_index_map.get(&1).is_none());
assert!(maps.tile_to_unflagged_auto_index_map.get(&128).is_none());
assert!(!maps.tile_to_unflagged_auto_index_map.contains_key(&1));
assert!(!maps.tile_to_unflagged_auto_index_map.contains_key(&128));

assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(0, 2)], 0);
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(0, 127)], 125);
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(2, 3)], 126);
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(126, 127)], 8000);
assert!(maps
assert!(!maps
.tile_to_unflagged_cross_baseline_map
.get(&(0, 1))
.is_none());
.contains_key(&(0, 1)));
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&0], (0, 2));
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&126], (2, 3));
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&8000], (126, 127));
assert!(maps
assert!(!maps
.unflagged_cross_baseline_to_tile_map
.get(&8001)
.is_none());
.contains_key(&8001));

assert_eq!(maps.unflagged_auto_index_to_tile_map[&0], 0);
assert_eq!(maps.unflagged_auto_index_to_tile_map[&1], 2);
Expand Down
6 changes: 3 additions & 3 deletions src/solutions/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn test_write_and_read_hyperdrive_solutions() {
// equality.
sols.di_jones
.into_iter()
.zip(sols_from_disk.di_jones.into_iter())
.zip(sols_from_disk.di_jones)
.for_each(|(expected, result)| {
if expected.any_nan() {
assert!(result.any_nan());
Expand Down Expand Up @@ -209,7 +209,7 @@ fn test_write_and_read_hyperdrive_solutions_no_metadata() {
// equality.
sols.di_jones
.into_iter()
.zip(sols_from_disk.di_jones.into_iter())
.zip(sols_from_disk.di_jones)
.for_each(|(expected, result)| {
if expected.any_nan() {
assert!(result.any_nan());
Expand Down Expand Up @@ -285,7 +285,7 @@ fn test_write_and_read_ao_solutions() {
// equality.
sols.di_jones
.into_iter()
.zip(sols_from_disk.di_jones.into_iter())
.zip(sols_from_disk.di_jones)
.for_each(|(expected, result)| {
if expected.any_nan() {
assert!(result.any_nan());
Expand Down
2 changes: 1 addition & 1 deletion src/srclist/rts/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub(crate) fn parse_source_list<T: std::io::BufRead>(
};

let float_to_int = |float: f64, line_num: u32| -> Result<usize, ReadSourceListCommonError> {
if float < 0.0 || float > std::u8::MAX as f64 {
if float < 0.0 || float > u8::MAX as f64 {
Err(ReadSourceListCommonError::FloatToIntError { line_num, float })
} else {
Ok(float as _)
Expand Down
2 changes: 1 addition & 1 deletion src/srclist/veto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub(crate) fn veto_sources(
// For this source, work out its smallest flux density at any of the
// coarse channel frequencies. This is how we determine which
// sources are "best".
let mut smallest_fd = std::f64::INFINITY;
let mut smallest_fd = f64::INFINITY;

// Filter trivial sources: are any of this source's components too
// low in elevation? Or too far from the phase centre?
Expand Down
2 changes: 1 addition & 1 deletion src/srclist/woden/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) fn parse_source_list<T: std::io::BufRead>(
};

let float_to_int = |float: f64, line_num: u32| -> Result<u32, ReadSourceListCommonError> {
if float < 0.0 || float > std::u32::MAX as f64 {
if float < 0.0 || float > u32::MAX as f64 {
Err(ReadSourceListCommonError::FloatToIntError { line_num, float })
} else {
Ok(float as u32)
Expand Down

0 comments on commit ff2f29a

Please sign in to comment.