Skip to content

Commit

Permalink
Fix failing read col tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrw committed Aug 5, 2024
1 parent 7160ed2 commit 6b2e609
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions fitsio/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::longnam::*;
use crate::stringutils::status_to_string;
use crate::types::DataType;
use std::ffi;
use std::mem::size_of;
use std::ops::Range;
use std::ptr;
use std::str::FromStr;
Expand Down Expand Up @@ -69,12 +68,7 @@ macro_rules! reads_col_impl {
test_name
)))?;
let col_desc = &column_descriptions[column_number];
#[allow(clippy::manual_bits)]
let repeat = if col_desc.data_type.typ == ColumnDataType::Bit {
col_desc.data_type.repeat / (size_of::<$t>() * 8)
} else {
col_desc.data_type.repeat
};
let repeat = col_desc.data_type.repeat;
let mut out = vec![$nullval; num_output_rows * repeat];
let mut status = 0;
unsafe {
Expand Down Expand Up @@ -397,15 +391,15 @@ macro_rules! writes_col_impl {
let colno = hdu.get_column_no(fits_file, col_name.into())?;
// TODO: check that the column exists in the file
let mut status = 0;
let n_rows = rows.end - rows.start;
let n_elements = (rows.end - rows.start);
unsafe {
fits_write_col(
fits_file.fptr.as_mut() as *mut _,
$data_type.into(),
(colno + 1) as _,
(rows.start + 1) as _,
1,
n_rows as _,
n_elements as _,
col_data.as_ptr() as *mut _,
&mut status,
);
Expand Down
2 changes: 1 addition & 1 deletion fitsio/tests/test_bit_datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn test_writing_bit_data_type() {
let mut f = FitsFile::open(file_path).unwrap();

let table_hdu = f.hdu("DATA").unwrap();
let flags: Vec<u32> = dbg!(table_hdu.read_col(&mut f, "BITMASK").unwrap());
let flags: Vec<u32> = table_hdu.read_col(&mut f, "BITMASK").unwrap();
assert_eq!(flags.len(), 64);
assert!(data.iter().zip(&flags).all(|(a, b)| a == b));
}

0 comments on commit 6b2e609

Please sign in to comment.