From 8ccb4db6646cfbb1690c4e418e54ba25dfa68be8 Mon Sep 17 00:00:00 2001 From: Erin Sheldon Date: Tue, 11 Jun 2024 10:36:59 -0400 Subject: [PATCH] add test case fitsio/tests/test_empty_slice.py --- fitsio/tests/test_empty_slice.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 fitsio/tests/test_empty_slice.py diff --git a/fitsio/tests/test_empty_slice.py b/fitsio/tests/test_empty_slice.py new file mode 100644 index 00000000..32c780b1 --- /dev/null +++ b/fitsio/tests/test_empty_slice.py @@ -0,0 +1,20 @@ +import tempfile +import os +import numpy as np +from ..fitslib import write, FITS + + +def test_empty_image_slice(): + shape = (10, 10) + data = np.arange(shape[0] * shape[1]).reshape(shape) + outfile = 'test_image.fits' + with tempfile.TemporaryDirectory() as tmpdir: + fname = os.path.join(tmpdir, 'test.fits') + write(fname, data, clobber=True) + + # third, test slices using fitsio + with FITS(outfile) as fits: + # first, passing the slices directly + # overlap = f[0][xslice, yslice] + overlap = fits[0][0:8, 0:0] + assert overlap.size == 0