There is a nice way of finding the nonzero min/max of an array excluding zeros described in here:
import numpy as np
minval = np.min(a[np.nonzero(a)])
maxval = np.max(a[np.nonzero(a)])
However, this won't work as soon as a
is a 2- or more dimensional array and an axis for the min/max is desired. Any simple solutions for that?