def _tosubslices(self, sl):
N = self.shape[self._distaxis]<EOL>start, stop, step = sl.start, sl.stop, sl.step<EOL>if step is None:<EOL><INDENT>step = <NUM_LIT:1><EOL><DEDENT>ss = []<EOL>ms = []<EOL>if step > <NUM_LIT:0>:<EOL><INDENT>if start is None:<EOL><INDENT>start = <NUM_LIT:0><EOL><DEDENT>if stop is None:<EOL><INDENT>stop = N<EOL><DEDENT>subs = range(<NUM_LIT:0>, self._n)<EOL>for s in subs:<EOL><INDENT>low = self._si[s]<EOL>high = self._si[s + <NUM_LIT:1>]<EOL>first = low + ((low - start) % step)<EOL>last = high + ((high - start) % step)<EOL>if start < high and stop > low and first < high:<EOL><INDENT>ss.append(s)<EOL>substart = max(first, start) - low<EOL>substop = min(last, stop) - low<EOL>ms.append(slice(substart, substop, step))<EOL><DEDENT><DEDENT><DEDENT>elif step < <NUM_LIT:0>:<EOL><INDENT>if start is None:<EOL><INDENT>start = N - <NUM_LIT:1><EOL><DEDENT>if stop is None:<EOL><INDENT>stop = -<NUM_LIT:1><EOL><DEDENT>subs = range(self._n - <NUM_LIT:1>, -<NUM_LIT:1>, -<NUM_LIT:1>)<EOL>for s in subs:<EOL><INDENT>low = self._si[s]<EOL>high = self._si[s + <NUM_LIT:1>]<EOL>first = high + step + ((high - start) % step)<EOL>last = low + step + ((low - start) % step)<EOL>if start >= low and stop < high and first >= low:<EOL><INDENT>ss.append(s)<EOL>substart = min(first, start) - low<EOL>substop = max(last + step, stop) - low<EOL>if substop < <NUM_LIT:0>:<EOL><INDENT>substop = None<EOL><DEDENT>ms.append(slice(substart, substop, step))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return ss, ms<EOL>
Maps a slice object for whole array to slice objects for subarrays.
        Returns pair (ss, ms) where ss is a list of subarrays and ms is a list
        giving the slice object that should be applied to each subarray.