On Thu, Sep 1, 2011 at 5:33 PM, Jonas Wallin <jonas.walli...@gmail.com>wrote:
> Hello, > > I implemented the following line of code: > > Gami[~index0].shape ----> (100,) > sigma.shape ----> (1,1) > Gami[~index0] = Gam[~index0] - sigma**2 > > I get the error message: > *** ValueError: array is not broadcastable to correct shape > > apparently > *temp* = Gam[~index0] - sigma**2 > *temp*.shape --> (1,100) > > Which seems strange to me is there any reason why *temp* gets this shape ? > Jonas, Numpy changes the shape of the output array based on certain broadcasting rules (See http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html). Broadcasting is really useful when you need it, but it can be confusing when you don't. Best, -Tony
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion