def roi_shape(roi):
    """
    Shape of an array after cropping with ``roi``.

    Same as ``xx[roi].shape``.
    """

    def slice_dim(s):
        return s.stop if s.start is None else s.stop - s.start

    if isinstance(roi, slice):
        roi = (roi,)

    return tuple(slice_dim(s) for s in roi)