From 8bf586b9763691fc7d68c69b7dbf7c9de29dec05 Mon Sep 17 00:00:00 2001 From: "Christopher H. Jordan" Date: Thu, 11 Aug 2022 12:07:34 +0800 Subject: [PATCH 1/4] Update changelog. How do I always forget this? --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 744e67d..75103ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Changes in each release are listed below. +## 0.15.1 09-Aug-2022 (Pre-release) +* mwalib now requires Rust version 1.57 or newer +* Speed up conversion of legacy -> MWAX visibility ordering +* Expose all mwalib error types + ## 0.15.0 23-Jun-2022 (Pre-release) * Provide DUT1 in the metafits context * API tweaks surrounding generic types From 5a40a53f729d90f269400724eff15d791dabe53c Mon Sep 17 00:00:00 2001 From: "Christopher H. Jordan" Date: Tue, 22 Nov 2022 14:27:57 +0800 Subject: [PATCH 2/4] Fix a bunch of clippy lints. --- CHANGELOG.md | 3 ++ build.rs | 4 +-- src/convert/mod.rs | 7 ++--- src/convert/test.rs | 30 ++++--------------- src/ffi/mod.rs | 58 ++++++++++++++---------------------- src/gpubox_files/mod.rs | 2 +- src/metafits_context/mod.rs | 8 ++--- src/metafits_context/test.rs | 26 ++++++++-------- src/rfinput/mod.rs | 6 ++-- src/timestep/test.rs | 12 ++++---- src/voltage_context/mod.rs | 12 ++++---- src/voltage_context/test.rs | 6 ++-- src/voltage_files/mod.rs | 2 +- src/voltage_files/test.rs | 8 ++--- 14 files changed, 79 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75103ac..be55140 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ Changes in each release are listed below. +## 0.16.0 (unreleased) +* Fixed a bunch of clippy lints. + ## 0.15.1 09-Aug-2022 (Pre-release) * mwalib now requires Rust version 1.57 or newer * Speed up conversion of legacy -> MWAX visibility ordering diff --git a/build.rs b/build.rs index 38c3003..f5cbdcc 100644 --- a/build.rs +++ b/build.rs @@ -4,9 +4,9 @@ use std::env; // (https://github.com/rust-lang/pkg-config-rs). fn infer_static(name: &str) -> bool { #[allow(clippy::if_same_then_else, clippy::needless_bool)] - if env::var(&format!("{}_STATIC", name.to_uppercase())).is_ok() { + if env::var(format!("{}_STATIC", name.to_uppercase())).is_ok() { true - } else if env::var(&format!("{}_DYNAMIC", name.to_uppercase())).is_ok() { + } else if env::var(format!("{}_DYNAMIC", name.to_uppercase())).is_ok() { false } else if env::var("PKG_CONFIG_ALL_STATIC").is_ok() { true diff --git a/src/convert/mod.rs b/src/convert/mod.rs index a7d00fa..d29a86b 100644 --- a/src/convert/mod.rs +++ b/src/convert/mod.rs @@ -253,8 +253,7 @@ pub(crate) fn generate_conversion_array(rf_inputs: &[Rfinput]) -> Vec = - Vec::with_capacity(baseline_count as usize); + let mut conversion_table: Vec = Vec::with_capacity(baseline_count); // Our row tile and column tile. Now 2 pols each so only 128 in legacy obs for row_tile in 0..128 { @@ -276,8 +275,8 @@ pub(crate) fn generate_conversion_array(rf_inputs: &[Rfinput]) -> Vec i32 { - let m = CStr::from_ptr(metafits_filename) - .to_str() - .unwrap() - .to_string(); + let m = CStr::from_ptr(metafits_filename).to_str().unwrap(); - let context = match MetafitsContext::new(&m, Some(mwa_version)) { + let context = match MetafitsContext::new(m, Some(mwa_version)) { Ok(c) => c, Err(e) => { set_c_string( @@ -268,12 +265,9 @@ pub unsafe extern "C" fn mwalib_metafits_context_new2( error_message: *const c_char, error_message_length: size_t, ) -> i32 { - let m = CStr::from_ptr(metafits_filename) - .to_str() - .unwrap() - .to_string(); + let m = CStr::from_ptr(metafits_filename).to_str().unwrap(); - let context = match MetafitsContext::new(&m, None) { + let context = match MetafitsContext::new(m, None) { Ok(c) => c, Err(e) => { set_c_string( @@ -433,7 +427,7 @@ pub unsafe extern "C" fn mwalib_metafits_context_free( } // Release correlator context if applicable - Box::from_raw(metafits_context_ptr); + drop(Box::from_raw(metafits_context_ptr)); // Return success MWALIB_SUCCESS @@ -473,10 +467,7 @@ pub unsafe extern "C" fn mwalib_correlator_context_new( error_message: *const c_char, error_message_length: size_t, ) -> i32 { - let m = CStr::from_ptr(metafits_filename) - .to_str() - .unwrap() - .to_string(); + let m = CStr::from_ptr(metafits_filename).to_str().unwrap(); let gpubox_slice = slice::from_raw_parts(gpubox_filenames, gpubox_count); let mut gpubox_files = Vec::with_capacity(gpubox_count); for g in gpubox_slice { @@ -952,7 +943,7 @@ pub unsafe extern "C" fn mwalib_correlator_context_free( return MWALIB_SUCCESS; } // Release correlator context if applicable - Box::from_raw(correlator_context_ptr); + drop(Box::from_raw(correlator_context_ptr)); // Return success MWALIB_SUCCESS @@ -992,10 +983,7 @@ pub unsafe extern "C" fn mwalib_voltage_context_new( error_message: *const c_char, error_message_length: size_t, ) -> i32 { - let m = CStr::from_ptr(metafits_filename) - .to_str() - .unwrap() - .to_string(); + let m = CStr::from_ptr(metafits_filename).to_str().unwrap(); let voltage_slice = slice::from_raw_parts(voltage_filenames, voltage_file_count); let mut voltage_files = Vec::with_capacity(voltage_file_count); for v in voltage_slice { @@ -1278,7 +1266,7 @@ pub unsafe extern "C" fn mwalib_voltage_context_free( return MWALIB_SUCCESS; } // Release voltage context if applicable - Box::from_raw(voltage_context_ptr); + drop(Box::from_raw(voltage_context_ptr)); // Return success MWALIB_SUCCESS @@ -1581,7 +1569,7 @@ pub unsafe extern "C" fn mwalib_metafits_metadata_get( input: *input, ant: *ant, tile_id: *tile_id, - tile_name: CString::new(String::from(&*tile_name)).unwrap().into_raw(), + tile_name: CString::new(String::from(tile_name)).unwrap().into_raw(), pol: CString::new(pol.to_string()).unwrap().into_raw(), electrical_length_m: *electrical_length_m, north_m: *north_m, @@ -1747,14 +1735,14 @@ pub unsafe extern "C" fn mwalib_metafits_metadata_get( jupiter_distance_deg: *jupiter_distance_deg, lst_deg: *lst_degrees, lst_rad: *lst_radians, - hour_angle_string: CString::new(String::from(&*hour_angle_string)) + hour_angle_string: CString::new(String::from(hour_angle_string)) .unwrap() .into_raw(), - grid_name: CString::new(String::from(&*grid_name)).unwrap().into_raw(), + grid_name: CString::new(String::from(grid_name)).unwrap().into_raw(), grid_number: grid_number.unwrap_or(-1), - creator: CString::new(String::from(&*creator)).unwrap().into_raw(), - project_id: CString::new(String::from(&*project_id)).unwrap().into_raw(), - obs_name: CString::new(String::from(&*obs_name)).unwrap().into_raw(), + creator: CString::new(String::from(creator)).unwrap().into_raw(), + project_id: CString::new(String::from(project_id)).unwrap().into_raw(), + obs_name: CString::new(String::from(obs_name)).unwrap().into_raw(), mode: *mode, geometric_delays_applied: *geometric_delays_applied, cable_delays_applied: *cable_delays_applied, @@ -1770,7 +1758,7 @@ pub unsafe extern "C" fn mwalib_metafits_metadata_get( delays: ffi_array_to_boxed_slice(delays.clone()), num_delays: *num_delays, calibrator: *calibrator, - calibrator_source: CString::new(String::from(&*calibrator_source)) + calibrator_source: CString::new(String::from(calibrator_source)) .unwrap() .into_raw(), sched_start_utc: sched_start_utc.timestamp(), @@ -1805,7 +1793,7 @@ pub unsafe extern "C" fn mwalib_metafits_metadata_get( obs_bandwidth_hz: *obs_bandwidth_hz, coarse_chan_width_hz: *coarse_chan_width_hz, centre_freq_hz: *centre_freq_hz, - metafits_filename: CString::new(String::from(&*metafits_filename)) + metafits_filename: CString::new(String::from(metafits_filename)) .unwrap() .into_raw(), } @@ -1879,14 +1867,14 @@ pub unsafe extern "C" fn mwalib_metafits_metadata_free( drop(Box::from_raw(i.tile_name)); drop(Box::from_raw(i.pol)); - if !(*i).digital_gains.is_null() { - drop(Box::from_raw((*i).digital_gains)); + if !i.digital_gains.is_null() { + drop(Box::from_raw(i.digital_gains)); } - if !(*i).dipole_gains.is_null() { - drop(Box::from_raw((*i).dipole_gains)); + if !i.dipole_gains.is_null() { + drop(Box::from_raw(i.dipole_gains)); } - if !(*i).dipole_delays.is_null() { - drop(Box::from_raw((*i).dipole_delays)); + if !i.dipole_delays.is_null() { + drop(Box::from_raw(i.dipole_delays)); } } diff --git a/src/gpubox_files/mod.rs b/src/gpubox_files/mod.rs index 590f919..52fe192 100644 --- a/src/gpubox_files/mod.rs +++ b/src/gpubox_files/mod.rs @@ -423,7 +423,7 @@ fn determine_hdu_time( let start_unix_time: u64 = get_required_fits_key!(gpubox_fptr, gpubox_hdu_fptr, "TIME")?; let start_unix_millitime: u64 = get_required_fits_key!(gpubox_fptr, gpubox_hdu_fptr, "MILLITIM")?; - Ok((start_unix_time * 1000 + start_unix_millitime) as u64) + Ok(start_unix_time * 1000 + start_unix_millitime) } /// Iterate over each HDU of the given gpubox file, tracking which UNIX times diff --git a/src/metafits_context/mod.rs b/src/metafits_context/mod.rs index 60f9151..e56cca7 100644 --- a/src/metafits_context/mod.rs +++ b/src/metafits_context/mod.rs @@ -27,7 +27,7 @@ mod test; /// Enum for all of the known variants of file format based on Correlator version /// #[repr(C)] -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum MWAVersion { /// MWA correlator (v1.0), having data files without any batch numbers. CorrOldLegacy = 1, @@ -106,7 +106,7 @@ impl fmt::Display for VisPol { } #[repr(C)] -#[derive(Debug, PartialEq, Clone, Copy, FromPrimitive)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, FromPrimitive)] pub enum GeometricDelaysApplied { No = 0, Zenith = 1, @@ -156,7 +156,7 @@ impl std::str::FromStr for GeometricDelaysApplied { } #[repr(C)] -#[derive(Debug, PartialEq, Clone, Copy, FromPrimitive)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, FromPrimitive)] pub enum CableDelaysApplied { NoCableDelaysApplied = 0, CableAndRecClock = 1, @@ -206,7 +206,7 @@ impl std::str::FromStr for CableDelaysApplied { } #[repr(C)] -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] #[allow(non_camel_case_types, clippy::upper_case_acronyms)] pub enum MWAMode { No_Capture = 0, diff --git a/src/metafits_context/test.rs b/src/metafits_context/test.rs index ad199c6..1bea784 100644 --- a/src/metafits_context/test.rs +++ b/src/metafits_context/test.rs @@ -16,7 +16,7 @@ fn test_metafits_context_new_invalid() { let metafits_filename = "invalid.metafits"; // No gpubox files provided - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::CorrMWAXv2)); + let context = MetafitsContext::new(metafits_filename, Some(MWAVersion::CorrMWAXv2)); assert!(context.is_err()); } @@ -30,7 +30,7 @@ fn test_metafits_context_new_vcs_legacy_valid() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSLegacyRecombined)) + let context = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSLegacyRecombined)) .expect("Failed to create MetafitsContext"); // rf_inputs: [Tile104Y, ..., Tile055X], @@ -63,7 +63,7 @@ fn test_metafits_context_new_corrlegacy_valid() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::CorrLegacy)) + let context = MetafitsContext::new(metafits_filename, Some(MWAVersion::CorrLegacy)) .expect("Failed to create MetafitsContext"); // Test the properties of the context object match what we expect @@ -268,7 +268,7 @@ fn test_metafits_context_new_corrmwaxv2_valid() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::CorrMWAXv2)) + let context = MetafitsContext::new(metafits_filename, Some(MWAVersion::CorrMWAXv2)) .expect("Failed to create MetafitsContext"); // Test the properties of the context object match what we expect @@ -292,7 +292,7 @@ fn test_metafits_context_new_vcsmwax2_valid() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSMWAXv2)) + let context = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSMWAXv2)) .expect("Failed to create MetafitsContext"); // Test the properties of the context object match what we expect @@ -326,7 +326,7 @@ fn test_populate_expected_timesteps() { for mwa_version in mwa_versions { // Open a context and load in a test metafits - let result = MetafitsContext::new_internal(&metafits_filename); + let result = MetafitsContext::new_internal(metafits_filename); assert!(result.is_ok()); @@ -367,7 +367,7 @@ fn test_populate_expected_coarse_channels_legacy() { for mwa_version in mwa_versions { // Open a context and load in a test metafits - let result = MetafitsContext::new_internal(&metafits_filename); + let result = MetafitsContext::new_internal(metafits_filename); assert!(result.is_ok()); @@ -410,7 +410,7 @@ fn test_populate_expected_coarse_channels_corr_mwaxv2() { for mwa_version in mwa_versions { // Open a context and load in a test metafits - let result = MetafitsContext::new_internal(&metafits_filename); + let result = MetafitsContext::new_internal(metafits_filename); assert!(result.is_ok()); @@ -450,7 +450,7 @@ fn test_metafits_context_new_guess_version() { let metafits_filename = "test_files/1101503312_1_timestep/1101503312.metafits"; // Open a context and load in a test metafits - let result = MetafitsContext::new(&metafits_filename, None); + let result = MetafitsContext::new(metafits_filename, None); assert!(result.is_ok()); let context = result.unwrap(); @@ -463,7 +463,7 @@ fn test_generate_expected_volt_filename_legacy_vcs() { let metafits_filename = "test_files/1101503312_1_timestep/1101503312.metafits"; // Open a context and load in a test metafits - let result = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSLegacyRecombined)); + let result = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSLegacyRecombined)); assert!(result.is_ok()); let context = result.unwrap(); @@ -479,7 +479,7 @@ fn test_generate_expected_volt_filename_mwax_vcs() { let metafits_filename = "test_files/1101503312_1_timestep/1101503312.metafits"; // Open a context and load in a test metafits - let result = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSMWAXv2)); + let result = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSMWAXv2)); assert!(result.is_ok()); let context = result.unwrap(); @@ -495,7 +495,7 @@ fn test_generate_expected_volt_filename_invalid_timestep() { let metafits_filename = "test_files/1101503312_1_timestep/1101503312.metafits"; // Open a context and load in a test metafits - let result = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSLegacyRecombined)); + let result = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSLegacyRecombined)); assert!(result.is_ok()); let context = result.unwrap(); @@ -509,7 +509,7 @@ fn test_generate_expected_volt_filename_invalid_coarse_chan() { let metafits_filename = "test_files/1101503312_1_timestep/1101503312.metafits"; // Open a context and load in a test metafits - let result = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSLegacyRecombined)); + let result = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSLegacyRecombined)); assert!(result.is_ok()); let context = result.unwrap(); diff --git a/src/rfinput/mod.rs b/src/rfinput/mod.rs index 4d85bce..2cd6098 100644 --- a/src/rfinput/mod.rs +++ b/src/rfinput/mod.rs @@ -45,7 +45,9 @@ fn get_vcs_order(input: u32) -> u32 { /// Second tile would have 2 for X, 3 for Y, etc. /// fn get_mwax_order(antenna: u32, pol: Pol) -> u32 { - (antenna * 2) + (if pol == Pol::Y { 1 } else { 0 }) + // `u32::from` converts the boolean to a number; in this case, 1 if pol is + // Y, 0 otherwise. + (antenna * 2) + u32::from(pol == Pol::Y) } /// Returns the electrical length for this rf_input. @@ -75,7 +77,7 @@ fn get_electrical_length(metafits_length_string: String, coax_v_factor: f64) -> } /// Instrument polarisation. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Pol { X, Y, diff --git a/src/timestep/test.rs b/src/timestep/test.rs index c2dae0e..487cc4a 100644 --- a/src/timestep/test.rs +++ b/src/timestep/test.rs @@ -375,7 +375,7 @@ fn test_timestep_new() { #[test] fn test_populate_timesteps_metafits_corr() { - let metafits_file = String::from("test_files/1101503312_1_timestep/1101503312.metafits"); + let metafits_file = "test_files/1101503312_1_timestep/1101503312.metafits"; let versions: Vec = vec![ MWAVersion::CorrOldLegacy, @@ -385,7 +385,7 @@ fn test_populate_timesteps_metafits_corr() { for mwa_version in versions { let metafits_context = - MetafitsContext::new_internal(&metafits_file).expect("Error creating metafits context"); + MetafitsContext::new_internal(metafits_file).expect("Error creating metafits context"); let timesteps = TimeStep::populate_timesteps( &metafits_context, @@ -410,10 +410,10 @@ fn test_populate_timesteps_metafits_corr() { #[test] fn test_populate_timesteps_metafits_vcs_legacy_recombined() { - let metafits_file = String::from("test_files/1101503312_1_timestep/1101503312.metafits"); + let metafits_file = "test_files/1101503312_1_timestep/1101503312.metafits"; let metafits_context = - MetafitsContext::new_internal(&metafits_file).expect("Error creating metafits context"); + MetafitsContext::new_internal(metafits_file).expect("Error creating metafits context"); let timesteps = TimeStep::populate_timesteps( &metafits_context, @@ -437,10 +437,10 @@ fn test_populate_timesteps_metafits_vcs_legacy_recombined() { #[test] fn test_populate_timesteps_metafits_vcs_mwaxv2() { - let metafits_file = String::from("test_files/1101503312_1_timestep/1101503312.metafits"); + let metafits_file = "test_files/1101503312_1_timestep/1101503312.metafits"; let metafits_context = - MetafitsContext::new_internal(&metafits_file).expect("Error creating metafits context"); + MetafitsContext::new_internal(metafits_file).expect("Error creating metafits context"); let timesteps = TimeStep::populate_timesteps( &metafits_context, diff --git a/src/voltage_context/mod.rs b/src/voltage_context/mod.rs index f5465fd..29283f8 100644 --- a/src/voltage_context/mod.rs +++ b/src/voltage_context/mod.rs @@ -656,7 +656,7 @@ impl VoltageContext { // Variables to keep track of where in the buffer we are writing to let mut start_pos: usize = 0; - let mut end_pos: usize = chunk_size as usize; + let mut end_pos: usize = chunk_size; // Loop through the timesteps / files for timestep_index in timestep_index_start..timestep_index_end + 1 { @@ -687,10 +687,10 @@ impl VoltageContext { }; // Open the file - let file_handle = File::open(&filename).expect("no file found"); + let file_handle = File::open(filename).expect("no file found"); // Obtain metadata - let metadata = std::fs::metadata(&filename).expect("unable to read metadata"); + let metadata = std::fs::metadata(filename).expect("unable to read metadata"); // Check file is as big as we expect if metadata.len() != calc_file_size { @@ -850,10 +850,10 @@ impl VoltageContext { }; // Open the file - let file_handle = File::open(&filename).expect("no file found"); + let file_handle = File::open(filename).expect("no file found"); // Obtain metadata - let metadata = std::fs::metadata(&filename).expect("unable to read metadata"); + let metadata = std::fs::metadata(filename).expect("unable to read metadata"); // Check file is as big as we expect // normally we would compare the file len to context.expected_voltage_data_file_size_bytes, @@ -890,7 +890,7 @@ impl VoltageContext { // Read the data into the final output buffer in blocks, spaced out with delay blocks (possibly) let mut start_pos: usize = 0; - let mut end_pos: usize = chunk_size as usize; + let mut end_pos: usize = chunk_size; // Loop until all data is read into our buffer for _ in 0..self.num_voltage_blocks_per_timestep { diff --git a/src/voltage_context/test.rs b/src/voltage_context/test.rs index bf133ae..dcbc7de 100644 --- a/src/voltage_context/test.rs +++ b/src/voltage_context/test.rs @@ -35,7 +35,7 @@ fn generate_test_voltage_file( initial_value: u8, ) -> Result { // initialization test data - let mut output_file: File = File::create(&filename)?; + let mut output_file: File = File::create(filename)?; // Write out header if one is needed if header_bytes > 0 { @@ -288,7 +288,7 @@ pub(crate) fn get_test_voltage_context(mwa_version: MWAVersion) -> VoltageContex // Note our test file only has 2 rfinputs, not 256! // Check the files are the right size // Obtain metadata - let metadata = std::fs::metadata(&test_filenames[0]).expect("unable to read metadata"); + let metadata = std::fs::metadata(test_filenames[0]).expect("unable to read metadata"); // Also check our test file is the right size! // Note our test files have 2 rfinputs, not 256, so we divide the block size by 128! @@ -308,7 +308,7 @@ fn test_context_new_missing_voltage_files() { let voltagefiles: Vec = Vec::new(); // No gpubox files provided - let context = VoltageContext::new(&metafits_filename, &voltagefiles); + let context = VoltageContext::new(metafits_filename, &voltagefiles); assert!(matches!( context.unwrap_err(), MwalibError::Voltage(VoltageFileError::NoVoltageFiles) diff --git a/src/voltage_files/mod.rs b/src/voltage_files/mod.rs index d1fbb37..50e8160 100644 --- a/src/voltage_files/mod.rs +++ b/src/voltage_files/mod.rs @@ -175,7 +175,7 @@ fn convert_temp_voltage_files( let batches = temp_voltage_files.iter().map(|g| g.gps_time_seconds); let mut voltage_file_batches: HashMap = HashMap::new(); for b in batches { - voltage_file_batches.insert(b, VoltageFileBatch::new(b as u64)); + voltage_file_batches.insert(b, VoltageFileBatch::new(b)); } for temp_v in temp_voltage_files.iter() { diff --git a/src/voltage_files/test.rs b/src/voltage_files/test.rs index 5a3b9ca..a210a67 100644 --- a/src/voltage_files/test.rs +++ b/src/voltage_files/test.rs @@ -553,7 +553,7 @@ fn test_examine_voltage_files_valid() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSMWAXv2)) + let context = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSMWAXv2)) .expect("Failed to create MetafitsContext"); // Create a temp dir for the temp files @@ -593,7 +593,7 @@ fn test_examine_voltage_files_error_mismatched_sizes() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSMWAXv2)) + let context = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSMWAXv2)) .expect("Failed to create MetafitsContext"); // Create a temp dir for the temp files @@ -641,7 +641,7 @@ fn test_examine_voltage_files_error_gpstime_gaps() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSMWAXv2)) + let context = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSMWAXv2)) .expect("Failed to create MetafitsContext"); // Create a temp dir for the temp files @@ -686,7 +686,7 @@ fn test_examine_voltage_files_error_file_not_found() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSMWAXv2)) + let context = MetafitsContext::new(metafits_filename, Some(MWAVersion::VCSMWAXv2)) .expect("Failed to create MetafitsContext"); // Populate vector of filenames From 5223fc00944860f6e2194857003aa9d11f2ea533 Mon Sep 17 00:00:00 2001 From: "Christopher H. Jordan" Date: Tue, 22 Nov 2022 14:37:39 +0800 Subject: [PATCH 3/4] Update dependencies. fitsio 0.20.0 uses a `PathBuf` instead of a `String` to track its filenames. This makes our code a little simpler. --- CHANGELOG.md | 1 + Cargo.toml | 2 +- src/fits_read/error.rs | 14 ++++++++------ src/fits_read/mod.rs | 20 ++++++++++---------- src/rfinput/error.rs | 8 +++++--- src/rfinput/mod.rs | 4 ++-- 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be55140..5b9cac8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Changes in each release are listed below. ## 0.16.0 (unreleased) +* Update dependencies. * Fixed a bunch of clippy lints. ## 0.15.1 09-Aug-2022 (Pre-release) diff --git a/Cargo.toml b/Cargo.toml index 718345b..c45b101 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ examples = ["anyhow", "clap", "env_logger"] [dependencies] chrono = "0.4.1" -fitsio = "0.19.0" +fitsio = "0.20.0" fitsio-sys = "0.4.0" lazy_static = "1.4.0" libc = "0.2.69" diff --git a/src/fits_read/error.rs b/src/fits_read/error.rs index 1164e5f..b3d10f5 100644 --- a/src/fits_read/error.rs +++ b/src/fits_read/error.rs @@ -6,6 +6,8 @@ Errors associated with reading in fits files. */ +use std::path::PathBuf; + use thiserror::Error; #[derive(Error, Debug)] @@ -14,7 +16,7 @@ pub enum FitsError { #[error("{source_file}:{source_line}\nCouldn't open {fits_filename}: {fits_error}")] Open { fits_error: fitsio::errors::Error, - fits_filename: String, + fits_filename: PathBuf, source_file: &'static str, source_line: u32, }, @@ -23,7 +25,7 @@ pub enum FitsError { #[error("{source_file}:{source_line}\n{fits_filename} HDU {hdu_num}: Couldn't find key {key}")] MissingKey { key: String, - fits_filename: String, + fits_filename: PathBuf, hdu_num: usize, source_file: &'static str, source_line: u32, @@ -32,7 +34,7 @@ pub enum FitsError { /// Error describing a HDU that couldn't be used as an image (e.g. `HduInfo::ImageInfo`). #[error("{source_file}:{source_line}\n{fits_filename} HDU {hdu_num}: Tried to use as an image, but not an image")] NotImage { - fits_filename: String, + fits_filename: PathBuf, hdu_num: usize, source_file: &'static str, source_line: u32, @@ -42,7 +44,7 @@ pub enum FitsError { #[error("{source_file}:{source_line}\n{fits_filename} HDU {hdu_num}: Couldn't read a long string from {key}")] LongString { key: String, - fits_filename: String, + fits_filename: PathBuf, hdu_num: usize, source_file: &'static str, source_line: u32, @@ -52,7 +54,7 @@ pub enum FitsError { #[error("{source_file}:{source_line}\n{fits_filename} HDU {hdu_num}: {fits_error}")] Fitsio { fits_error: fitsio::errors::Error, - fits_filename: String, + fits_filename: PathBuf, hdu_num: usize, source_file: &'static str, source_line: u32, @@ -62,7 +64,7 @@ pub enum FitsError { #[error("{source_file}:{source_line}\nCouldn't parse {key} in {fits_filename} HDU {hdu_num}")] Parse { key: String, - fits_filename: String, + fits_filename: PathBuf, hdu_num: usize, source_file: &'static str, source_line: u32, diff --git a/src/fits_read/mod.rs b/src/fits_read/mod.rs index 69a0e0f..6bc0e1b 100644 --- a/src/fits_read/mod.rs +++ b/src/fits_read/mod.rs @@ -288,7 +288,7 @@ pub fn _open_fits>( } Err(e) => Err(FitsError::Open { fits_error: e, - fits_filename: file.as_ref().to_str().unwrap().to_string(), + fits_filename: file.as_ref().to_path_buf(), source_file, source_line, }), @@ -309,7 +309,7 @@ pub fn _open_hdu( Ok(f) => { trace!( "_open_hdu() filename: '{}' hdu: {}", - fits_fptr.filename, + fits_fptr.filename.display(), hdu_num ); Ok(f) @@ -371,7 +371,7 @@ pub fn _get_optional_fits_key( trace!( "_get_optional_fits_key() filename: '{}' hdu: {} keyword: '{}' value: '{}'", - &fits_fptr.filename, + fits_fptr.filename.display(), hdu.number, String::from(keyword), unparsed_value @@ -381,7 +381,7 @@ pub fn _get_optional_fits_key( Ok(parsed_value) => Ok(Some(parsed_value)), Err(_) => Err(FitsError::Parse { key: keyword.to_string(), - fits_filename: fits_fptr.filename.to_string(), + fits_filename: fits_fptr.filename.clone(), hdu_num: hdu.number + 1, source_file, source_line, @@ -404,7 +404,7 @@ pub fn _get_required_fits_key( Ok(Some(value)) => Ok(value), Ok(None) => Err(FitsError::MissingKey { key: keyword.to_string(), - fits_filename: fits_fptr.filename.to_string(), + fits_filename: fits_fptr.filename.clone(), hdu_num: hdu.number + 1, source_file, source_line, @@ -428,7 +428,7 @@ pub fn _get_fits_col( Ok(c) => { trace!( "_get_fits_col() filename: '{}' hdu: {} keyword: '{}' values: {}", - fits_fptr.filename, + fits_fptr.filename.display(), hdu.number, keyword, c.len() @@ -504,7 +504,7 @@ pub fn _get_optional_fits_key_long_string( trace!( "_get_optional_fits_key_long_string() filename: {} keyword: '{}' value: '{:?}'", - &fits_fptr.filename, + fits_fptr.filename.display(), keyword, long_string ); @@ -555,7 +555,7 @@ pub fn _get_hdu_image_size( HduInfo::ImageInfo { shape, .. } => { trace!( "_get_hdu_image_size() filename: '{}' hdu: {} shape: {:?}", - fits_fptr.filename, + fits_fptr.filename.display(), hdu.number, shape ); @@ -585,7 +585,7 @@ pub fn _get_fits_image( Ok(img) => { trace!( "_get_fits_image() filename: '{}' hdu: {}", - fits_fptr.filename, + fits_fptr.filename.display(), hdu.number ); Ok(img) @@ -651,7 +651,7 @@ pub fn _get_fits_float_img_into_buf( trace!( "_get_fits_float_img_into_buf() filename: '{}' hdu: {}", - fits_fptr.filename, + fits_fptr.filename.display(), hdu.number ); diff --git a/src/rfinput/error.rs b/src/rfinput/error.rs index f43d640..7fb5613 100644 --- a/src/rfinput/error.rs +++ b/src/rfinput/error.rs @@ -6,6 +6,8 @@ Errors associated with reading in rfinput data. */ +use std::path::PathBuf; + use thiserror::Error; #[derive(Error, Debug)] @@ -13,7 +15,7 @@ pub enum RfinputError { /// Error when reading from an MWA metafits table cell. #[error("{fits_filename} HDU {hdu_num}: Failed to read table row {row_num} for {col_name} from metafits")] ReadCell { - fits_filename: String, + fits_filename: PathBuf, hdu_num: usize, row_num: usize, col_name: String, @@ -22,7 +24,7 @@ pub enum RfinputError { /// Error when reading in a Rfinput's polarisation. #[error("{fits_filename} HDU {hdu_num}: Did not recognise the polarisation at in row {row_num} ({got}); expected X or Y")] UnrecognisedPol { - fits_filename: String, + fits_filename: PathBuf, hdu_num: usize, row_num: usize, got: String, @@ -31,7 +33,7 @@ pub enum RfinputError { /// Error when attempting to read a cell array. #[error("{fits_filename} HDU {hdu_num}: Failed to read cell array from column {col_name}, row {row_num} from metafits")] CellArray { - fits_filename: String, + fits_filename: PathBuf, hdu_num: usize, row_num: i64, col_name: String, diff --git a/src/rfinput/mod.rs b/src/rfinput/mod.rs index 2cd6098..c03ef57 100644 --- a/src/rfinput/mod.rs +++ b/src/rfinput/mod.rs @@ -383,7 +383,7 @@ fn read_cell_value( Ok(c) => { trace!( "read_cell_value() filename: '{}' hdu: {} col_name: '{}' row '{}'", - &metafits_fptr.filename, + metafits_fptr.filename.display(), metafits_tile_table_hdu.number, col_name, row @@ -459,7 +459,7 @@ fn read_cell_array( trace!( "read_cell_array() filename: '{}' hdu: {} col_name: '{}' row '{}'", - &metafits_fptr.filename, + metafits_fptr.filename.display(), metafits_tile_table_hdu.number, col_name, row From 41e1d1c427fb4d800480017cbeb7fb3aafbf3a87 Mon Sep 17 00:00:00 2001 From: "Christopher H. Jordan" Date: Tue, 22 Nov 2022 15:21:32 +0800 Subject: [PATCH 4/4] Update module docs. I've just changed them from the "block style" to the nicer alternative. I also changed the lib.rs documentation to something other than a message to the code reader :) --- CHANGELOG.md | 1 + src/antenna/mod.rs | 5 ++--- src/antenna/test.rs | 5 ++--- src/baseline/mod.rs | 5 ++--- src/baseline/test.rs | 5 ++--- src/coarse_channel/error.rs | 4 +--- src/coarse_channel/mod.rs | 5 ++--- src/coarse_channel/test.rs | 5 ++--- src/convert/mod.rs | 9 ++++----- src/convert/test.rs | 5 ++--- src/correlator_context/mod.rs | 5 ++--- src/correlator_context/test.rs | 5 ++--- src/error.rs | 5 ++--- src/ffi/mod.rs | 4 +--- src/ffi/test.rs | 5 ++--- src/fits_read/error.rs | 4 +--- src/fits_read/mod.rs | 5 ++--- src/fits_read/test.rs | 5 ++--- src/gpubox_files/error.rs | 4 +--- src/gpubox_files/mod.rs | 5 ++--- src/gpubox_files/test.rs | 5 ++--- src/lib.rs | 8 ++++---- src/metafits_context/error.rs | 5 ++--- src/metafits_context/mod.rs | 5 ++--- src/metafits_context/test.rs | 5 ++--- src/misc/mod.rs | 5 ++--- src/misc/test.rs | 5 ++--- src/rfinput/error.rs | 4 +--- src/rfinput/mod.rs | 5 ++--- src/rfinput/test.rs | 7 +++---- src/timestep/mod.rs | 5 ++--- src/timestep/test.rs | 5 ++--- src/voltage_context/mod.rs | 5 ++--- src/voltage_context/test.rs | 5 ++--- src/voltage_files/error.rs | 5 ++--- src/voltage_files/mod.rs | 5 ++--- src/voltage_files/test.rs | 5 ++--- 37 files changed, 73 insertions(+), 112 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b9cac8..1807d70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Changes in each release are listed below. ## 0.16.0 (unreleased) +* Update module docs. * Update dependencies. * Fixed a bunch of clippy lints. diff --git a/src/antenna/mod.rs b/src/antenna/mod.rs index 480dced..1da305e 100644 --- a/src/antenna/mod.rs +++ b/src/antenna/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Structs and helper methods for antenna metadata -*/ +//! Structs and helper methods for antenna metadata + use crate::rfinput::*; use std::fmt; diff --git a/src/antenna/test.rs b/src/antenna/test.rs index d2b005f..c9443ee 100644 --- a/src/antenna/test.rs +++ b/src/antenna/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for antenna metadata -*/ +//! Unit tests for antenna metadata + #[cfg(test)] use super::*; use float_cmp::*; diff --git a/src/baseline/mod.rs b/src/baseline/mod.rs index b1abc6a..e3d5a93 100644 --- a/src/baseline/mod.rs +++ b/src/baseline/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Structs and helper methods for baseline metadata -*/ +//! Structs and helper methods for baseline metadata + use crate::misc; use std::fmt; diff --git a/src/baseline/test.rs b/src/baseline/test.rs index 5abb1f6..7889bec 100644 --- a/src/baseline/test.rs +++ b/src/baseline/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for baseline metadata -*/ +//! Unit tests for baseline metadata + #[cfg(test)] use super::*; diff --git a/src/coarse_channel/error.rs b/src/coarse_channel/error.rs index f15f3ee..d672415 100644 --- a/src/coarse_channel/error.rs +++ b/src/coarse_channel/error.rs @@ -2,9 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Errors associated with coarse channels. -*/ +//! Errors associated with coarse channels. use thiserror::Error; diff --git a/src/coarse_channel/mod.rs b/src/coarse_channel/mod.rs index 4fddea9..30ba613 100644 --- a/src/coarse_channel/mod.rs +++ b/src/coarse_channel/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Structs and helper methods for coarse channel metadata -*/ +//! Structs and helper methods for coarse channel metadata + use crate::gpubox_files::GpuboxTimeMap; use crate::voltage_files::VoltageFileTimeMap; pub mod error; diff --git a/src/coarse_channel/test.rs b/src/coarse_channel/test.rs index 7c9a7dd..131fe0e 100644 --- a/src/coarse_channel/test.rs +++ b/src/coarse_channel/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for coarse channel metadata -*/ +//! Unit tests for coarse channel metadata + #[cfg(test)] use super::*; use float_cmp::*; diff --git a/src/convert/mod.rs b/src/convert/mod.rs index d29a86b..aa353a6 100644 --- a/src/convert/mod.rs +++ b/src/convert/mod.rs @@ -2,12 +2,11 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Structs and helper methods for coverting Legacy MWA data into a sensible ordering/format. +//! Structs and helper methods for coverting Legacy MWA data into a sensible +//! ordering/format. +//! +//! Major contributor: Brian Crosse (Curtin Institute for Radio Astronomy) -Major contributor: Brian Crosse (Curtin Institute for Radio Astronomy) - -*/ use crate::misc::*; use crate::rfinput::*; use log::trace; diff --git a/src/convert/test.rs b/src/convert/test.rs index eec9b50..42b296f 100644 --- a/src/convert/test.rs +++ b/src/convert/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for code dealing with conversion from legacy to mwax format -*/ +//! Unit tests for code dealing with conversion from legacy to mwax format + #[cfg(test)] use super::*; use crate::*; diff --git a/src/correlator_context/mod.rs b/src/correlator_context/mod.rs index 63dcba9..9522568 100644 --- a/src/correlator_context/mod.rs +++ b/src/correlator_context/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -The main interface to MWA data. - */ +//! The main interface to MWA data. + use std::collections::BTreeMap; use std::fmt; use std::path::Path; diff --git a/src/correlator_context/test.rs b/src/correlator_context/test.rs index f43a4f4..ab7ef8d 100644 --- a/src/correlator_context/test.rs +++ b/src/correlator_context/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for correlator context -*/ +//! Unit tests for correlator context + use super::*; use float_cmp::*; use std::path::PathBuf; diff --git a/src/error.rs b/src/error.rs index f22859b..0b869d2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,9 +1,8 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Structs and helper methods for Error handling -*/ + +//! Structs and helper methods for Error handling use thiserror::Error; diff --git a/src/ffi/mod.rs b/src/ffi/mod.rs index 450b01a..478b000 100644 --- a/src/ffi/mod.rs +++ b/src/ffi/mod.rs @@ -2,9 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -This module exists purely for other languages to interface with mwalib. - */ +//! This module exists purely for other languages to interface with mwalib. use crate::*; use gpubox_files::GpuboxError; diff --git a/src/ffi/test.rs b/src/ffi/test.rs index 2416df5..78c0da3 100644 --- a/src/ffi/test.rs +++ b/src/ffi/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for ffi module -*/ +//! Unit tests for ffi module + #[cfg(test)] use super::*; use float_cmp::*; diff --git a/src/fits_read/error.rs b/src/fits_read/error.rs index b3d10f5..47dff3f 100644 --- a/src/fits_read/error.rs +++ b/src/fits_read/error.rs @@ -2,9 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Errors associated with reading in fits files. - */ +//! Errors associated with reading in fits files. use std::path::PathBuf; diff --git a/src/fits_read/mod.rs b/src/fits_read/mod.rs index 6bc0e1b..c2376cc 100644 --- a/src/fits_read/mod.rs +++ b/src/fits_read/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Helper functions for reading FITS files. - */ +//! Helper functions for reading FITS files. + pub mod error; pub use error::FitsError; diff --git a/src/fits_read/test.rs b/src/fits_read/test.rs index e6d88b2..dd3d568 100644 --- a/src/fits_read/test.rs +++ b/src/fits_read/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for fits reading functions -*/ +//! Unit tests for fits reading functions + #[cfg(test)] use super::*; use crate::misc::test::*; diff --git a/src/gpubox_files/error.rs b/src/gpubox_files/error.rs index 94c092e..3963dcc 100644 --- a/src/gpubox_files/error.rs +++ b/src/gpubox_files/error.rs @@ -2,9 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Errors associated with reading in gpubox files. -*/ +//! Errors associated with reading in gpubox files. use thiserror::Error; diff --git a/src/gpubox_files/mod.rs b/src/gpubox_files/mod.rs index 52fe192..3720dbe 100644 --- a/src/gpubox_files/mod.rs +++ b/src/gpubox_files/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Functions for organising and checking the consistency of gpubox files. -*/ +//! Functions for organising and checking the consistency of gpubox files. + pub mod error; use std::collections::BTreeMap; diff --git a/src/gpubox_files/test.rs b/src/gpubox_files/test.rs index 1b0fb29..e25dba5 100644 --- a/src/gpubox_files/test.rs +++ b/src/gpubox_files/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for gpubox file metadata -*/ +//! Unit tests for gpubox file metadata + #[cfg(test)] use super::*; use crate::misc::test::*; diff --git a/src/lib.rs b/src/lib.rs index 1110b49..e0f53ad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,10 +2,10 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Definitions for what we expose to the library -Public items will be exposed as mwalib::module. -*/ +//! A library to simplify reading Murchison Widefield Array (MWA) raw visibilities, voltages and metadata. + +// Definitions for what we expose to the library +// Public items will be exposed as mwalib::module. mod antenna; mod baseline; mod coarse_channel; diff --git a/src/metafits_context/error.rs b/src/metafits_context/error.rs index 282b546..66cc86f 100644 --- a/src/metafits_context/error.rs +++ b/src/metafits_context/error.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Errors associated with reading in metafits files. -*/ +//! Errors associated with reading in metafits files. + use crate::MWAMode; use thiserror::Error; diff --git a/src/metafits_context/mod.rs b/src/metafits_context/mod.rs index e56cca7..d417e01 100644 --- a/src/metafits_context/mod.rs +++ b/src/metafits_context/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -The main interface to MWA data. - */ +//! The main interface to MWA data. + use std::fmt; use std::path::Path; diff --git a/src/metafits_context/test.rs b/src/metafits_context/test.rs index 1bea784..1b9a9cf 100644 --- a/src/metafits_context/test.rs +++ b/src/metafits_context/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for metafits context -*/ +//! Unit tests for metafits context + use std::str::FromStr; #[cfg(test)] diff --git a/src/misc/mod.rs b/src/misc/mod.rs index 60f88a6..b7fb0a6 100644 --- a/src/misc/mod.rs +++ b/src/misc/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -General helper/utility methods -*/ +//! General helper/utility methods + use crate::antenna; use std::{mem, slice}; diff --git a/src/misc/test.rs b/src/misc/test.rs index cdc831c..a8cdfe1 100644 --- a/src/misc/test.rs +++ b/src/misc/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for misc utility functions -*/ +//! Unit tests for misc utility functions + #[cfg(test)] use super::*; use crate::antenna::*; diff --git a/src/rfinput/error.rs b/src/rfinput/error.rs index 7fb5613..76ea5eb 100644 --- a/src/rfinput/error.rs +++ b/src/rfinput/error.rs @@ -2,9 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Errors associated with reading in rfinput data. -*/ +//! Errors associated with reading in rfinput data. use std::path::PathBuf; diff --git a/src/rfinput/mod.rs b/src/rfinput/mod.rs index c03ef57..4e70ef9 100644 --- a/src/rfinput/mod.rs +++ b/src/rfinput/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Structs and helper methods for rf_input metadata -*/ +//! Structs and helper methods for rf_input metadata + pub mod error; use error::RfinputError; use log::trace; diff --git a/src/rfinput/test.rs b/src/rfinput/test.rs index ec0fc42..010e8b6 100644 --- a/src/rfinput/test.rs +++ b/src/rfinput/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for rfinput metadata -*/ +//! Unit tests for rfinput metadata + #[cfg(test)] use super::*; use crate::misc::test::*; @@ -215,7 +214,7 @@ fn test_populate_rf_inputs() { 68. / 64., float_cmp::F64Margin::default() )); - + assert_eq!( rfinput[0].dipole_delays, vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] diff --git a/src/timestep/mod.rs b/src/timestep/mod.rs index 01f51e6..e55a6d0 100644 --- a/src/timestep/mod.rs +++ b/src/timestep/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Structs and helper methods for timestep metadata -*/ +//! Structs and helper methods for timestep metadata + use crate::gpubox_files::GpuboxTimeMap; use crate::misc; use crate::voltage_files::VoltageFileTimeMap; diff --git a/src/timestep/test.rs b/src/timestep/test.rs index 487cc4a..069264a 100644 --- a/src/timestep/test.rs +++ b/src/timestep/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for timestep metadata -*/ +//! Unit tests for timestep metadata + #[cfg(test)] use super::*; use crate::gpubox_files::GpuboxTimeMap; diff --git a/src/voltage_context/mod.rs b/src/voltage_context/mod.rs index 29283f8..2a8ca9d 100644 --- a/src/voltage_context/mod.rs +++ b/src/voltage_context/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -The main interface to MWA voltage data. - */ +//! The main interface to MWA voltage data. + use crate::coarse_channel::*; use crate::error::*; use crate::metafits_context::*; diff --git a/src/voltage_context/test.rs b/src/voltage_context/test.rs index dcbc7de..6a112d9 100644 --- a/src/voltage_context/test.rs +++ b/src/voltage_context/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for voltage context -*/ +//! Unit tests for voltage context + #[cfg(test)] use super::*; use float_cmp::*; diff --git a/src/voltage_files/error.rs b/src/voltage_files/error.rs index c106d72..4edc8f2 100644 --- a/src/voltage_files/error.rs +++ b/src/voltage_files/error.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Errors associated with reading in voltage files. -*/ +//! Errors associated with reading in voltage files. + use crate::MWAVersion; use thiserror::Error; diff --git a/src/voltage_files/mod.rs b/src/voltage_files/mod.rs index 50e8160..6530ba8 100644 --- a/src/voltage_files/mod.rs +++ b/src/voltage_files/mod.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Functions for organising and checking the consistency of voltage files. -*/ +//! Functions for organising and checking the consistency of voltage files. + pub mod error; use crate::*; pub use error::VoltageFileError; diff --git a/src/voltage_files/test.rs b/src/voltage_files/test.rs index a210a67..a3b400f 100644 --- a/src/voltage_files/test.rs +++ b/src/voltage_files/test.rs @@ -2,9 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -/*! -Unit tests for voltage file metadata -*/ +//! Unit tests for voltage file metadata + #[cfg(test)] use super::*; use std::fs::File;