[Numpy-discussion] Silent Broadcasting considered harmful
Eric Firing
efiring at hawaii.edu
Sun Feb 8 19:12:52 EST 2015
On 2015/02/08 12:43 PM, josef.pktd at gmail.com wrote:
>
> For me the main behavior I had to adjust to was loosing a dimension in
> any reduce operation, mean, sum, ...
>
> if x is 2d
> x - x.mean(1)
> we loose a dimension, and it doesn't broadcast in the right direction
Though you can use:
x_demeaned = x - np.mean(x, axis=1, keepdims=True)
>
> x - x.mean(0)
> perfect, no `repeat` needed, it just broadcasts the way we need.
>
> Josef
More information about the NumPy-Discussion
mailing list