def squish(r, axis):
    """
    Squish array along an axis.

    Determine the sum along all but one axis for an array.

    Parameters
    ----------
    r : ndarray
        Array to squish.
    axis : int
        Axis of r to squish along.

    Returns
    -------
    s : 1D ndarray
        Array r squished into a single dimension.

    """
    # put axis to be squished as the last axis
    N = int(r.ndim)
    r = r.swapaxes(axis, N - 1)

    # sum along leading axis N-1 times
    for i in range(N - 1):
        r = r.sum(0)
    return r