def vec_subvec(a, r):
    """
    Extracts a sub-vector from a given vector

    Parameters
    ----------
    a: list[]
        A vector of scalar values
    r: tuple
        A pair (ps, pe) indicating the start and end points of the
        sub-vector dimension. If ps>pe then the sub-vector will be
        reversed. Values must be positive.

    Returns
    -------
    list[]
        The sub-vector

    """
    assert len(r) == 2
    assert min(r) >= 0

    step = 1 if r[0] <= r[1] else -1

    return (a[r[0]:: step] if r[0] > r[1] == 0 else
            a[r[0]: r[1] + step: step])