def parse_slice(slice_string):
    """
    Parse a slice given as a string.

    Parameters
    ----------
    slice_string : str
        String describing the slice. Format as in fancy indexing: 'start:stop:end'.

    Returns
    -------
        slice

    Examples
    --------

    Everything supported in fancy indexing works here, too:

    >>> parse_slice('5')
    slice(5, 6, None)
    >>> parse_slice(':5')
    slice(None, 5, None)
    >>> parse_slice('5:')
    slice(5, None, None)
    >>> parse_slice('2:5')
    slice(2, 5, None)
    >>> parse_slice('2:5:3')
    slice(2, 5, 3)
    >>> parse_slice('::3')
    slice(None, None, 3)

    """
    slice_string.replace(' ', '')
    indices = slice_string.split(':')
    if len(indices) == 1:
        start, stop, step = indices[0], int(indices[0]) + 1, None
    elif len(indices) == 2:
        start, stop, step = indices[0], indices[1], None
    elif len(indices) == 3:
        start, stop, step = indices
    else:
        raise RuntimeError
    start = int(start) if start != '' else None
    stop = int(stop) if stop != '' else None
    step = int(step) if step is not None and step != '' else None
    return slice(start, stop, step)
