[Numpy-discussion] the difference between "+" and np.add?

Chao YUE chaoyuejoy@gmail....
Thu Nov 22 06:41:34 CST 2012


Dear all,

if I have two ndarray arr1 and arr2 (with the same shape), is there some
difference when I do:

arr = arr1 + arr2

and

arr = np.add(arr1, arr2),

and then if I have more than 2 arrays: arr1, arr2, arr3, arr4, arr5, then I
cannot use np.add anymore as it only recieves 2 arguments.
then what's the best practice to add these arrays? should I do

arr = arr1 + arr2 + arr3 + arr4 + arr5

or I do

arr = np.sum(np.array([arr1, arr2, arr3, arr4, arr5]), axis=0)?

because I just noticed recently that there are functions like np.add,
np.divide, np.substract... before I am using all like directly arr1/arr2,
rather than np.divide(arr1,arr2).

best regards,

Chao

-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20121122/e556cce8/attachment.html 


More information about the NumPy-Discussion mailing list