[Numpy-tickets] [NumPy] #380: broadcasting problem?: - differs from -= and + differs from +=

NumPy numpy-tickets at scipy.net
Tue Nov 14 15:39:29 CST 2006


#380: broadcasting problem?: - differs from  -= and + differs from +=
------------------------+---------------------------------------------------
 Reporter:  holistone   |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:          
Component:  numpy.core  |     Version:          
 Severity:  normal      |    Keywords:          
------------------------+---------------------------------------------------
 a = ones((3,2))[[BR]]
 print a-a[0][[BR]]
 [[ 0.  0.] [ 0.  0.] [ 0.  0.]][[BR]]
 a -= a[0][[BR]]
 print a[[BR]]
 [[ 0.  0.] [ 1.  1.] [ 1.  1.]][[BR]][[BR]]

 a = ones((3,2))[[BR]]
 a+a[0][[BR]]
 array([[ 2.,  2.], [ 2.,  2.], [ 2.,  2.]])[[BR]]
 a += a[0][[BR]]
 a[[BR]]
 array([[ 2.,  2.], [ 3.,  3.], [ 3.,  3.]])[[BR]]
 I expected the same result in both cases.
 Is this the intended behavior?

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/380>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list