Does numpy include in all * its functions?

Say I have two objects X, a Yshape k,1,nand a k,m,n. I know that numpy will automatically extend / repeat Xin the first dimension when I perform operations such as X + Y. Does this magic work for all math operations that are supported / included in numpy?

For example, can I do scipy.special.binom(X,Y)and get the expected result? I have tried some of the special functions and I am not getting an error message. Having not received the error, let me conclude that the broadcast was performed correctly?

+4
source share
1 answer

numpy , . * + -/ .. , , ufunc. ufunc.

scipy.special.binom, a ufunc. , , , :

In [379]: special.binom([1,2,3],[[1],[2]])
Out[379]: 
array([[ 1.,  2.,  3.],
       [ 0.,  1.,  3.]])

In [380]: special.binom([1,2,3,4],[[1],[2]])
Out[380]: 
array([[ 1.,  2.,  3.,  4.],
       [ 0.,  1.,  3.,  6.]])

In [385]: special.binom(np.arange(6).reshape(3,2,1),np.arange(6).reshape(3,1,2)).shape
Out[385]: (3, 2, 2)

(2,3) (2,4) . .

np.dot numpy, .

+6

All Articles