[Numpy-discussion] add axis to results of reduction (mean, min, ...)
Tue Aug 18 03:22:03 CDT 2009
Keith Goodman wrote:
> On Thu, Aug 6, 2009 at 9:58 AM, Charles R
> Harris<firstname.lastname@example.org> wrote:
>> On Thu, Aug 6, 2009 at 9:55 AM, <email@example.com> wrote:
>>> What's the best way of getting back the correct shape to be able to
>>> broadcast, mean, min,.. to the original array, that works for
>>> arbitrary dimension and axis?
>>> I thought I have seen some helper functions, but I don't find them
>> Adding a keyword to retain the number of dimensions has been mooted. It
>> shouldn't be too difficult to implement and would allow things like:
>>>>> scaled = a/a.max(1, reduce=0)
>> I could do that for 1.4 if folks are interested.
> I'd use that. It's better than what I usually do:
> scaled = a / a.max(1).reshape(-1,1)
To chime in after returning from holidays: I'd use that keyword a great
deal. Would be more than welcome to me. I currently have loads of code
numpy.newaxis-ing the results of min/max/mean operations...
More information about the NumPy-Discussion