[Numpy-discussion] using reducing functions without eliminating dimensions?
Tue Apr 7 13:44:58 CDT 2009
I often want to use some kind of dimension-reducing function (like min(),
max(), sum(), mean()) on an array without actually removing the last
dimension, so that I can then do operations broadcasting the reduced
array back to the size of the full array. Full example:
>> table - table.min(axis=1)
ValueError: shape mismatch: objects cannot be broadcast to a single
>> table - table.min(axis=1)[:, newaxis]
I have to resort to ugly code with lots of stuff like "... axis=1)[:,
Is there any way to get the reducing functions to leave a size-1 dummy
dimension in place, to make this easier?
More information about the Numpy-discussion