From: Paul F. D. <pa...@pf...> - 2002-02-14 18:05:43
|
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 21.0b2. 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. |