> I think it would enhance broadcasting if functions like sum, mean, etc
> didn't change the number of dimensions.
I strongly favor doing it, but with keepshape (or just "keep", to make
it short) and not by default. It's at least as common to take a mean
down an axis of a 2D array and plot it (requiring 1D) as to subtract
it in a broadcasting way. But, the latter case is common.
How about generalizing it to take a mean of more than one axis at a
time, say to reduce 4 dimensions to 1 for plotting? That could be
done by accepting a linear list of axis numbers to average over.
a = ones((2,3,4,5))
b = a.mean([1,2,3])
I'd add an option to handle NaN data as missing, as well. That's
standard in other array languages. The option is called "NAN" in IDL
and I'd propose that name as well.
Also, from the docstring...
to compute the standard deviation of the flattened array.
should say
to compute the mean of the flattened array.
Oops. But, it emphasizes the point that these behaviors should be
universal to similar routines. Are there other routines for which
these behaviors would not work well?
--jh--