[Numpy-discussion] Proposal, recoded average.
Paul F. Dubois
paul at pfdubois.com
Thu Feb 14 10:06:22 CST 2002
I recoded the new average function in both Numeric and MA. This version
ensures that in the returned=1 case the weights returned will be of the
same shape as the average. The new version is in CVS and labeled as
The average now allows weights that, rather than having to be the same
size as the input, can be the same size as the input's axis'th
dimension. This relieves the user of the rather tricky code needed to
make an array of a given shape broadcasting a vector along a certain
axis. This is a relatively frequent need and so I will write a separate
routine for it soon. My proposed calling sequence is:
def broadcast(v, axis=0, s)
"""Returns an array of the type of v and the shape s, such that
setting the axis'th
subscript to j results in an array whose values are all v[j].
Comments about this idea or the way I explain it would be welcome.
More information about the Numpy-discussion