def reduce_array_shape(shape):
    """ Reduce the shape of a NumPy array

    * Trim trailing ones
    * Check that remaining non-zero dimension sizes are equal

    Args:
        shape (:obj:`list` of :obj:`int`): shape of array

    Returns:
        :obj:`:obj:`list` of :obj:`int`: reduced shape
    """
    shape = list(shape)

    while shape and shape[-1] == 1:
        shape.pop()

    return shape