In almost all cases np.ndim(x)==0 should be used instead of this
function, as that will also return true for 0d arrays. This is how
numpy overloads functions in the style of the dx arguments to gradient
and the bins argument to histogram. Some key differences: