(Only a note to the two other answers on this page.)
To enter two input values, you can check the data type of the object that np.power will return by checking the types attribute:
>>> np.power.types ['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L', 'qq->q', 'QQ->Q', 'ee->e', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D', 'GG->G', 'OO->O']
Python-compatible integer types are denoted by the l characters compatible with the Python d () boards.
np.power effectively decides what to return by checking the types of arguments passed and using the first appropriate signature from this list.
So, given 10 and -100, np.power match the signature integer integer -> integer and return the integer 0 .
On the other hand, if one of the arguments is float, then integer will also be transferred to float , and float float -> float (and the correct float value will be returned).
Alex Riley Feb 04 '15 at 21:31 2015-02-04 21:31
source share