def _get_slice_len(idx):
    """
    Get the number of elements in a slice.

    Parameters
    ----------
    idx : np.ndarray
        A (3,) shaped array containing start, stop, step

    Returns
    -------
    n : int
        The length of the slice.

    Examples
    --------
    >>> idx = np.array([5, 15, 5])
    >>> _get_slice_len(idx)
    2
    """
    start, stop, step = idx[0], idx[1], idx[2]

    if step > 0:
        return (stop - start + step - 1) // step
    else:
        return (start - stop - step - 1) // (-step)