def mmin(ar):
    """
    Take the min value over an array of arbitrary dimension. Works for
    slices and other arrays where ar.flat is undefined.
    """
    if len(ar.shape) == 1:
        return min(ar)
    else:
        return min([mmin(x) for x in ar])