Skip to content

Commit

Permalink
FIX empty slice case
Browse files Browse the repository at this point in the history
  • Loading branch information
esheldon committed Jun 11, 2024
1 parent bf983bb commit d621316
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fitsio/hdu/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,11 @@ def _read_image_slice(self, arg):
step = -1

# Sanity checks for proper syntax.
if (step > 0 and stop < start) or (step < 0 and start < stop):
if ((step > 0 and stop < start)
or (step < 0 and start < stop)
or (start == stop)):
return numpy.empty(0, dtype=npy_dtype)

if start < 0:
start = dims[dim] + start
if start < 0:
Expand All @@ -293,6 +296,7 @@ def _read_image_slice(self, arg):

if stop > dims[dim]:
stop = dims[dim]

if stop < start:
# A little black magic here. The stop is offset by 2 to
# accommodate the 1-offset of CFITSIO, and to move past the end
Expand Down

0 comments on commit d621316

Please sign in to comment.