def wrap_check_stop(l, stop):
    """Check that stop index falls in (-l, l] and wrap negative values to l + stop.
    
    For convenience, stop == 0 is assumed to be shorthand for stop == l.
    
    """
    if (stop <= -l) or (stop > l):
        raise IndexError('stop index out of range')
    elif stop <= 0:
        # let stop == 0 be shorthand for stop == l,
        # i.e. including all profiles to the end
        stop = (stop - 1) % l + 1
    return stop