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

So inspect doesn't return arguments for numpy function, because it does not recognize it as function, while numpy doesn't seem to have helper function that would return function's arguments.

Does anyone know how to get arguments for arbitrary numpy function?

2
  • 6
    All ufuncs have the same signature. The only differences are the number of in and outputs, and those are available as .nin and .nout Commented Mar 27, 2013 at 20:27
  • @seberg it would be nice if you posted your comment as the right answer since it solved the problem... Commented May 2, 2013 at 19:59

1 Answer 1

2

copied from the comments above --> credits to Seberg

All ufuncs have the same signature. The only differences are the number of in and outputs, and those are available as

.nin

and

.nout 

– seberg Mar 27 '13 at 20:27

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for accepting the answer - it was not mine, so the credits must go to the author; this was my modest contribution to the backlog of unanswered questions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.