code: def _range_from_slice(myslice, start=None, stop=None, step=None, length=None):
      
      assert isinstance(myslice, slice)
      # Find 'step'.
      step = myslice.step if myslice.step is not None else step
      if step is None:
          step = 1
      # Find 'start'.
      start = myslice.start if myslice.start is not None else start
      if start is None:
          start = 0
      # Find 'stop' as a function of length if 'stop' is unspecified.
      stop = myslice.stop if myslice.stop is not None else stop
      if length is not None:
          stop_inferred = floor(start + step * length)
          if stop is not None and stop < stop_inferred:
              raise ValueError("'stop' ({stop}) and ".format(stop=stop) +
                               "'length' ({length}) ".format(length=length) +
                               "are not compatible.")
          stop = stop_inferred
      if stop is None and length is None:
          raise ValueError("'stop' and 'length' cannot be both unspecified.")
      myrange = np.arange(start, stop, step)
      # Check the length if it was specified.
      if length is not None:
          assert len(myrange) == length
      return myrange
docs: Convert a slice to an array of integers.