def _read_image_slice(self, arg):
if '<STR_LIT>' not in self._info:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if isinstance(arg, slice):<EOL><INDENT>return self._read_image_slice((arg,))<EOL><DEDENT>if not isinstance(arg, tuple):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>nd = len(arg)<EOL>if nd != self._info['<STR_LIT>']:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % (nd, self._info['<STR_LIT>']))<EOL><DEDENT>targ = arg<EOL>arg = []<EOL>for a in targ:<EOL><INDENT>if isinstance(a, slice):<EOL><INDENT>arg.append(a)<EOL><DEDENT>elif isinstance(a, int):<EOL><INDENT>arg.append(slice(a, a+<NUM_LIT:1>, <NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>dims = self._info['<STR_LIT>']<EOL>arrdims = []<EOL>first = []<EOL>last = []<EOL>steps = []<EOL>dim = <NUM_LIT:0><EOL>for slc in arg:<EOL><INDENT>start = slc.start<EOL>stop = slc.stop<EOL>step = slc.step<EOL>if start is None:<EOL><INDENT>start = <NUM_LIT:0><EOL><DEDENT>if stop is None:<EOL><INDENT>stop = dims[dim]<EOL><DEDENT>if step is None:<EOL><INDENT>step = <NUM_LIT:1><EOL><DEDENT>if step < <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if start < <NUM_LIT:0>:<EOL><INDENT>start = dims[dim] + start<EOL>if start < <NUM_LIT:0>:<EOL><INDENT>raise IndexError("<STR_LIT>")<EOL><DEDENT><DEDENT>if stop < <NUM_LIT:0>:<EOL><INDENT>stop = dims[dim] + start + <NUM_LIT:1><EOL><DEDENT>start = start + <NUM_LIT:1><EOL>if stop < start:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % slc)<EOL><DEDENT>if stop > dims[dim]:<EOL><INDENT>stop = dims[dim]<EOL><DEDENT>first.append(start)<EOL>last.append(stop)<EOL>steps.append(step)<EOL>arrdims.append(stop-start+<NUM_LIT:1>)<EOL>dim += <NUM_LIT:1><EOL><DEDENT>first.reverse()<EOL>last.reverse()<EOL>steps.reverse()<EOL>first = numpy.array(first, dtype='<STR_LIT>')<EOL>last = numpy.array(last, dtype='<STR_LIT>')<EOL>steps = numpy.array(steps, dtype='<STR_LIT>')<EOL>npy_dtype = self._get_image_numpy_dtype()<EOL>array = numpy.zeros(arrdims, dtype=npy_dtype)<EOL>self._FITS.read_image_slice(self._ext+<NUM_LIT:1>, first, last, steps, array)<EOL>return array<EOL>
workhorse to read a slice