3
>>> import inspect
>>> import numpy as np
>>> inspect.getargspec(np.abs)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\inspect.py", line 815, in getargspec
    raise TypeError('{!r} is not a Python function'.format(func))
TypeError: <ufunc 'absolute'> is not a Python function

所以inspect不返回函数的参数numpy,因为它不将其识别为函数,而numpy似乎没有帮助函数返回函数的参数。

有谁知道如何获取任意 numpy 函数的参数?

4

1 回答 1

2

从上面的评论中复制-> 归功于 Seberg

所有 ufunc 都具有相同的签名。唯一的区别是输入和输出的数量,这些可以作为

.nin

.nout 

——seberg 2013 年 3 月 27 日在 20:27

https://stackoverflow.com/users/455221/seberg

于 2014-05-13T06:05:48.853 回答