Skip to content

Commit

Permalink
Clippy lints and update cbindgen.
Browse files Browse the repository at this point in the history
cast_abs_to_unsigned is a fun one.
  • Loading branch information
cjordan committed Jun 16, 2022
1 parent 38a5fe8 commit c4ade0f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tempdir = "0.3.6"

[build-dependencies]
built = "0.5.0"
cbindgen = "0.21.0"
cbindgen = "0.24.0"

[[example]]
name = "mwalib-data-dump"
Expand Down
8 changes: 4 additions & 4 deletions src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ impl LegacyConversionBaseline {
baseline,
ant1,
ant2,
xx_index: xx.abs() as usize,
xx_index: xx.unsigned_abs() as usize,
xx_conjugate: xx < 0,
xy_index: xy.abs() as usize,
xy_index: xy.unsigned_abs() as usize,
xy_conjugate: xy < 0,
yx_index: yx.abs() as usize,
yx_index: yx.unsigned_abs() as usize,
yx_conjugate: yx < 0,
yy_index: yy.abs() as usize,
yy_index: yy.unsigned_abs() as usize,
yy_conjugate: yy < 0,
}
}
Expand Down
32 changes: 14 additions & 18 deletions src/ffi/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1741,18 +1741,16 @@ fn test_mwalib_metafits_metadata_get_from_metafits_context_legacy_vcs_valid() {
//
// Test antennas
//
let item: Vec<Antenna> =
let items: Vec<Antenna> =
ffi_boxed_slice_to_array(metafits_metadata.antennas, metafits_metadata.num_ants);

assert_eq!(item.len(), 128, "Array length is not correct");

for i in 0..128 {
if item[i].tile_id == 154 {
assert_eq!(item[i].rfinput_y, 1);
}
assert_eq!(items.len(), 128, "Array length is not correct");

if item[i].tile_id == 104 {
assert_eq!(item[i].rfinput_y, 0);
for item in items {
if item.tile_id == 154 {
assert_eq!(item.rfinput_y, 1);
} else if item.tile_id == 104 {
assert_eq!(item.rfinput_y, 0);
}
}
}
Expand Down Expand Up @@ -1872,18 +1870,16 @@ fn test_mwalib_metafits_metadata_get_from_voltage_context_valid() {
//
// Test antennas
//
let item: Vec<Antenna> =
let items: Vec<Antenna> =
ffi_boxed_slice_to_array(metafits_metadata.antennas, metafits_metadata.num_ants);

assert_eq!(item.len(), 128, "Array length is not correct");

for i in 0..128 {
if item[i].tile_id == 154 {
assert_eq!(item[i].rfinput_y, 1);
}
assert_eq!(items.len(), 128, "Array length is not correct");

if item[i].tile_id == 104 {
assert_eq!(item[i].rfinput_y, 0);
for item in items {
if item.tile_id == 154 {
assert_eq!(item.rfinput_y, 1);
} else if item.tile_id == 104 {
assert_eq!(item.rfinput_y, 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/metafits_context/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn test_metafits_context_new_corrlegacy_valid() {
assert_eq!(context.delays[15], 0);

// Calibrator
assert_eq!(context.calibrator, false);
assert!(!context.calibrator);
assert_eq!(context.calibrator_source, "");

// Global attenuation: 1 dB,
Expand Down
12 changes: 4 additions & 8 deletions src/voltage_context/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ pub(crate) fn get_index_for_location_in_test_voltage_file_legacy(
rfinput_index: usize,
) -> usize {
let num_rfinputs = 2;
let rf: usize;
let fc: usize;

// Note for legacy always only have 1 block (i.e. no concept of a block)
let bytes_per_rfinput = 1;
Expand All @@ -165,10 +163,10 @@ pub(crate) fn get_index_for_location_in_test_voltage_file_legacy(
let s = sample_index * bytes_per_sample;

// Now within the sample, move to the correct fine chan
fc = fine_chan_index * bytes_per_fine_chan;
let fc = fine_chan_index * bytes_per_fine_chan;

// Now within the fine channel get the rf_input
rf = rfinput_index * bytes_per_rfinput;
let rf = rfinput_index * bytes_per_rfinput;

// Return the correct index
s + rf + fc
Expand All @@ -183,8 +181,6 @@ pub(crate) fn get_index_for_location_in_test_voltage_file_mwaxv2(
) -> usize {
let num_finechan = 1;
let num_rfinputs = 2;
let vb: usize;
let rf: usize;

let bytes_per_fine_chan = 64000 * 2;

Expand All @@ -193,10 +189,10 @@ pub(crate) fn get_index_for_location_in_test_voltage_file_mwaxv2(
let bytes_per_voltage_block = num_rfinputs * bytes_per_rfinput;

// This will position us at the correct block
vb = voltage_block_index * bytes_per_voltage_block;
let vb = voltage_block_index * bytes_per_voltage_block;

// Now within the block, move to the correct rf_input
rf = rfinput_index * bytes_per_rfinput;
let rf = rfinput_index * bytes_per_rfinput;

// Return the correct index
vb + rf + (sample_index * 2) + value_index
Expand Down

0 comments on commit c4ade0f

Please sign in to comment.