Skip to content

Commit ff2f29a

Browse files
committed
fix linter issues, downgrade vec1 for msrv compatibility
1 parent 8762cf9 commit ff2f29a

File tree

15 files changed

+40
-48
lines changed

15 files changed

+40
-48
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [
66
"Dev Null <dev.null@curtin.edu.au>",
77
]
88
edition = "2021"
9-
rust-version = "1.68"
9+
rust-version = "1.68" # `cargo +1.68 build --locked` works, but technically development needs 1.73
1010
license = "MPL-2.0"
1111
readme = "README.md"
1212
description = "Calibration software for the Murchison Widefield Array (MWA) radio telescope"
@@ -96,7 +96,8 @@ strum = "0.24.0"
9696
strum_macros = "0.24.0"
9797
thiserror = "1.0.7"
9898
toml = "0.7.2"
99-
vec1 = { version = "1.5.0", features = ["serde"] }
99+
# TODO: bump vec1 after msrv update
100+
vec1 = { version = "~1.10.0", features = ["serde"] }
100101

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

115116
[dev-dependencies]
116117
approx = "0.5.1"
117-
assert_cmd = "2.0.0"
118+
assert_cmd = "2.0.0" # 2.0.14 requires Rust 1.73.0
118119
criterion = { version = "0.4.0", default_features = false }
119120
indoc = "2.0.1"
120121
marlu = { version = "0.11.0", features = ["approx"] }

src/beam/tests.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ use serial_test::serial;
1010

1111
use super::*;
1212

13-
#[cfg(any(feature = "cuda", feature = "hip"))]
14-
use approx::abs_diff_eq;
15-
1613
#[test]
1714
fn no_beam_means_no_beam() {
1815
let azels = [

src/cli/solutions/apply/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn test_solutions_apply_trivial(mut args: SolutionsApplyArgs) {
287287
// Remove the newly-flagged chanblocks. (This is awkward because SPWs
288288
// weren't designed to be modified.)
289289
params.input_vis_params.spw.chanblocks = (0..)
290-
.zip(params.input_vis_params.spw.chanblocks.into_iter())
290+
.zip(params.input_vis_params.spw.chanblocks)
291291
.filter(|(i, _)| !flagged_fine_chans.contains(i))
292292
.map(|(_, c)| c)
293293
.collect();

src/cli/solutions/plot/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,7 @@ mod plotting {
602602
x_axis
603603
.values()
604604
.zip(amps.iter().map(|g| g[pol_index]))
605-
.filter(|(_, y)| !y.is_nan())
606-
.map(|(x, y)| (x, y)),
605+
.filter(|(_, y)| !y.is_nan()),
607606
1,
608607
if [0, 3].contains(&pol_index) {
609608
ShapeStyle::from(&colour).filled()

src/flagging/mwaf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ mod tests {
605605
assert_eq!(s[6], 128);
606606
assert_eq!(s[7], 3);
607607

608-
let expected = vec![
608+
let expected = [
609609
0.99999946,
610610
0.99999946,
611611
0.08406332,
@@ -670,7 +670,7 @@ mod tests {
670670
assert_eq!(s[6], 128);
671671
assert_eq!(s[7], 3);
672672

673-
let expected = vec![
673+
let expected = [
674674
0.99999946,
675675
0.99999946,
676676
0.08051342,

src/io/read/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub(crate) trait VisRead: Sync + Send {
8686

8787
/// Read auto-correlation visibilities for all frequencies and tiles in a
8888
/// single timestep into the `data_array` and similar for the weights.
89+
#[allow(dead_code)] // this is used in tests
8990
fn read_autos(
9091
&self,
9192
vis_fb: ArrayViewMut2<Jones<f32>>,

src/io/read/ms/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,12 @@ fn test_timestep_reading() {
415415
let phase_centre = RADec::from_degrees(0., -27.);
416416
let array_pos = LatLngHeight::mwa();
417417
#[rustfmt::skip]
418-
let tile_xyzs = vec![
418+
let tile_xyzs = [
419419
XyzGeodetic { x: 0., y: 0., z: 0., },
420420
XyzGeodetic { x: 1., y: 0., z: 0., },
421421
XyzGeodetic { x: 0., y: 1., z: 0., },
422422
];
423-
let tile_names = vec!["tile_0_0", "tile_1_0", "tile_0_1"];
423+
let tile_names = ["tile_0_0", "tile_1_0", "tile_0_1"];
424424

425425
let marlu_obs_ctx = MarluObsContext {
426426
sched_start_timestamp: Epoch::from_gpst_seconds(obsid as f64),

src/io/write/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ fn can_write_to_file_inner(file: &Path) -> Result<bool, FileWriteError> {
548548
match std::fs::OpenOptions::new()
549549
.write(true)
550550
.create(true)
551+
.truncate(true)
551552
.open(file)
552553
.map_err(|e| e.kind())
553554
{

src/io/write/tests.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,10 @@ fn test_vis_output_no_time_averaging_no_gaps() {
176176
});
177177

178178
let result: Result<Result<(), VisWriteError>, _> = data_handle.join();
179-
let result = match result {
179+
match result {
180180
Err(_) | Ok(Err(_)) => result.map(|_| Ok(String::new())),
181181
Ok(Ok(())) => write_handle.join(),
182-
};
183-
result
182+
}
184183
});
185184

186185
match scoped_threads_result {
@@ -379,11 +378,10 @@ fn test_vis_output_no_time_averaging_with_gaps() {
379378
});
380379

381380
let result: Result<Result<(), VisWriteError>, _> = data_handle.join();
382-
let result = match result {
381+
match result {
383382
Err(_) | Ok(Err(_)) => result.map(|_| Ok(String::new())),
384383
Ok(Ok(())) => write_handle.join(),
385-
};
386-
result
384+
}
387385
});
388386

389387
match scoped_threads_result {
@@ -586,11 +584,10 @@ fn test_vis_output_time_averaging() {
586584
});
587585

588586
let result: Result<Result<(), VisWriteError>, _> = data_handle.join();
589-
let result = match result {
587+
match result {
590588
Err(_) | Ok(Err(_)) => result.map(|_| Ok(String::new())),
591589
Ok(Ok(())) => write_handle.join(),
592-
};
593-
result
590+
}
594591
});
595592

596593
match scoped_threads_result {

src/math/tests.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,21 @@ fn test_tile_baseline_flags_without_flags() {
4848
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(0, 1)], 0);
4949
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(0, 127)], 126);
5050
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(126, 127)], 8127);
51-
assert!(maps
51+
assert!(!maps
5252
.tile_to_unflagged_cross_baseline_map
53-
.get(&(0, 0))
54-
.is_none());
53+
.contains_key(&(0, 0)));
5554
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&0], (0, 1));
5655
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&8127], (126, 127));
57-
assert!(maps
56+
assert!(!maps
5857
.unflagged_cross_baseline_to_tile_map
59-
.get(&8128)
60-
.is_none());
58+
.contains_key(&8128));
6159

6260
assert_eq!(maps.tile_to_unflagged_auto_index_map[&0], 0);
6361
assert_eq!(maps.tile_to_unflagged_auto_index_map[&127], 127);
64-
assert!(maps.tile_to_unflagged_auto_index_map.get(&128).is_none());
62+
assert!(!maps.tile_to_unflagged_auto_index_map.contains_key(&128));
6563
assert_eq!(maps.unflagged_auto_index_to_tile_map[&0], 0);
6664
assert_eq!(maps.unflagged_auto_index_to_tile_map[&127], 127);
67-
assert!(maps.unflagged_auto_index_to_tile_map.get(&128).is_none());
65+
assert!(!maps.unflagged_auto_index_to_tile_map.contains_key(&128));
6866

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

@@ -84,24 +82,22 @@ fn test_tile_baseline_flags() {
8482
let maps = TileBaselineFlags::new(total_num_tiles, tile_flags);
8583
assert_eq!(maps.tile_to_unflagged_auto_index_map[&0], 0);
8684
assert_eq!(maps.tile_to_unflagged_auto_index_map[&2], 1);
87-
assert!(maps.tile_to_unflagged_auto_index_map.get(&1).is_none());
88-
assert!(maps.tile_to_unflagged_auto_index_map.get(&128).is_none());
85+
assert!(!maps.tile_to_unflagged_auto_index_map.contains_key(&1));
86+
assert!(!maps.tile_to_unflagged_auto_index_map.contains_key(&128));
8987

9088
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(0, 2)], 0);
9189
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(0, 127)], 125);
9290
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(2, 3)], 126);
9391
assert_eq!(maps.tile_to_unflagged_cross_baseline_map[&(126, 127)], 8000);
94-
assert!(maps
92+
assert!(!maps
9593
.tile_to_unflagged_cross_baseline_map
96-
.get(&(0, 1))
97-
.is_none());
94+
.contains_key(&(0, 1)));
9895
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&0], (0, 2));
9996
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&126], (2, 3));
10097
assert_eq!(maps.unflagged_cross_baseline_to_tile_map[&8000], (126, 127));
101-
assert!(maps
98+
assert!(!maps
10299
.unflagged_cross_baseline_to_tile_map
103-
.get(&8001)
104-
.is_none());
100+
.contains_key(&8001));
105101

106102
assert_eq!(maps.unflagged_auto_index_to_tile_map[&0], 0);
107103
assert_eq!(maps.unflagged_auto_index_to_tile_map[&1], 2);

src/solutions/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn test_write_and_read_hyperdrive_solutions() {
106106
// equality.
107107
sols.di_jones
108108
.into_iter()
109-
.zip(sols_from_disk.di_jones.into_iter())
109+
.zip(sols_from_disk.di_jones)
110110
.for_each(|(expected, result)| {
111111
if expected.any_nan() {
112112
assert!(result.any_nan());
@@ -209,7 +209,7 @@ fn test_write_and_read_hyperdrive_solutions_no_metadata() {
209209
// equality.
210210
sols.di_jones
211211
.into_iter()
212-
.zip(sols_from_disk.di_jones.into_iter())
212+
.zip(sols_from_disk.di_jones)
213213
.for_each(|(expected, result)| {
214214
if expected.any_nan() {
215215
assert!(result.any_nan());
@@ -285,7 +285,7 @@ fn test_write_and_read_ao_solutions() {
285285
// equality.
286286
sols.di_jones
287287
.into_iter()
288-
.zip(sols_from_disk.di_jones.into_iter())
288+
.zip(sols_from_disk.di_jones)
289289
.for_each(|(expected, result)| {
290290
if expected.any_nan() {
291291
assert!(result.any_nan());

src/srclist/rts/read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) fn parse_source_list<T: std::io::BufRead>(
4646
};
4747

4848
let float_to_int = |float: f64, line_num: u32| -> Result<usize, ReadSourceListCommonError> {
49-
if float < 0.0 || float > std::u8::MAX as f64 {
49+
if float < 0.0 || float > u8::MAX as f64 {
5050
Err(ReadSourceListCommonError::FloatToIntError { line_num, float })
5151
} else {
5252
Ok(float as _)

src/srclist/veto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub(crate) fn veto_sources(
6363
// For this source, work out its smallest flux density at any of the
6464
// coarse channel frequencies. This is how we determine which
6565
// sources are "best".
66-
let mut smallest_fd = std::f64::INFINITY;
66+
let mut smallest_fd = f64::INFINITY;
6767

6868
// Filter trivial sources: are any of this source's components too
6969
// low in elevation? Or too far from the phase centre?

src/srclist/woden/read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub(crate) fn parse_source_list<T: std::io::BufRead>(
6565
};
6666

6767
let float_to_int = |float: f64, line_num: u32| -> Result<u32, ReadSourceListCommonError> {
68-
if float < 0.0 || float > std::u32::MAX as f64 {
68+
if float < 0.0 || float > u32::MAX as f64 {
6969
Err(ReadSourceListCommonError::FloatToIntError { line_num, float })
7070
} else {
7171
Ok(float as u32)

0 commit comments

Comments
 (0)