-
Notifications
You must be signed in to change notification settings - Fork 770
Closed
Description
How do you pass a variable list of arguments in pythonnet? The problem is the function numpy.gradient(f, *varargs, axis=None, edge_order=1) as documented here: https://numpy.org/doc/stable/reference/generated/numpy.gradient.html
Here is an example in python
>>> import numpy as np
>>> dx=4.0
>>> dy=5.0
>>> zX=[[1,2,3],[4,5,6],[8,9,0]]
>>> np.gradient(zX, dx, dy)
[array([[ 0.75 , 0.75 , 0.75 ],
[ 0.875, 0.875, -0.375],
[ 1. , 1. , -1.5 ]]), array([[ 0.2, 0.2, 0.2],
[ 0.2, 0.2, 0.2],
[ 0.2, -0.8, -1.8]])]
>>>I tried to pass the variable args with the args tuple but then the python function complains that the number of arguments is incorrect.
Python.Runtime.PythonException: TypeError : invalid number of arguments
[' File "C:\\Users\\henon\\AppData\\Local\\python-3.7.3-embed-amd64\\lib\\numpy\\lib\\function_base.py", line 1013, in gradient\n raise TypeError("invalid number of arguments")\n'] at Python.Runtime.PyObject.Invoke(PyTuple args, PyDict kw)
at Python.Runtime.PyObject.InvokeMethod(String name, PyTuple args, PyDict kw)
I also tried to pass it as kw["varargs"] but then python says there is no kwarg named "varargs"
So how to call that function?
Metadata
Metadata
Assignees
Labels
No labels