def validate_intervals(intervals):
    """Checks that an (n, 2) interval ndarray is well-formed, and raises errors
    if not.

    Parameters
    ----------
    intervals : np.ndarray, shape=(n, 2)
        Array of interval start/end locations.

    """
    if intervals.ndim != 2 or intervals.shape[1] != 2:
        raise ValueError(
            'Intervals should be n-by-2 numpy ndarray, but shape={}'.format
            (intervals.shape))
    if (intervals < 0).any():
        raise ValueError('Negative interval times found')
    if (intervals[:, (1)] <= intervals[:, (0)]).any():
        raise ValueError('All interval durations must be strictly positive')
