Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fitsio/src/fitsfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1401,8 +1401,8 @@ mod test {
.unwrap();

assert_eq!(read_data.len(), (6 - 2) * (17 - 11) * (7 - 3));
assert_eq!(read_data[0], 614);
assert_eq!(read_data[50], 958);
assert_eq!(read_data[0], 689);
assert_eq!(read_data[50], 1223);
});
}

Expand Down
14 changes: 9 additions & 5 deletions fitsio/src/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ macro_rules! read_image_impl_vec {
let mut lpixel = Vec::with_capacity(n_ranges);

let mut nelements = 1;
for range in ranges {
// Reverse the ranges to match CFITSIO's Fortran column-major
// convention, since the user provides ranges in C row-major order
for range in ranges.iter().rev() {
let start = range.start + 1;
// No +1 as the range is exclusive
let end = range.end;
Expand Down Expand Up @@ -254,7 +256,9 @@ macro_rules! write_image_impl {
let mut fpixel = Vec::with_capacity(n_ranges);
let mut lpixel = Vec::with_capacity(n_ranges);

for range in ranges {
// Reverse the ranges to match CFITSIO's Fortran column-major
// convention, since the user provides ranges in C row-major order
for range in ranges.iter().rev() {
let start = range.start + 1;
// No +1 as the range is exclusive
let end = range.end;
Expand Down Expand Up @@ -441,8 +445,8 @@ mod tests {

let chunk: Vec<i32> = hdu.read_region(&mut f, &[&ycoord, &xcoord]).unwrap();
assert_eq!(chunk.len(), (7 - 5) * (3 - 2));
assert_eq!(chunk[0], 168);
assert_eq!(chunk[chunk.len() - 1], 112);
assert_eq!(chunk[0], 101);
assert_eq!(chunk[chunk.len() - 1], 171);
}

#[test]
Expand Down Expand Up @@ -494,7 +498,7 @@ mod tests {
let chunk: Vec<i64> = hdu.read_region(&mut f, &[&(0..10), &(0..5)]).unwrap();
assert_eq!(chunk.len(), 10 * 5);
assert_eq!(chunk[0], 50);
assert_eq!(chunk[25], 80);
assert_eq!(chunk[25], 75);
});
}

Expand Down
5 changes: 3 additions & 2 deletions fitsio/tests/test_square_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ fn test_square_array() {
* 15, 16, 17, 18, 19,
* 20, 21, 22, 23, 24]
*
* We check that the x-values (1..3) (exclusive of the top end), and y-values (2..4)
* We check that rows (1..3) (exclusive of the top end), and columns (2..4)
* (exclusive of the top end) return what we expect.
* Ranges follow C row-major convention: [rows, columns].
*/
let filename = "../testdata/square_array.fits";
let mut f = FitsFile::open(filename).unwrap();
let phdu = f.primary_hdu().unwrap();

let ranges = vec![&(1..3), &(2..4)];
let data: Vec<u32> = phdu.read_region(&mut f, &ranges).unwrap();
assert_eq!(data, vec![11, 12, 16, 17]);
assert_eq!(data, vec![7, 8, 12, 13]);
}
Loading