I have imported scipy.interpolate.Rbf
from python to Julia 1.6
using PyCall
. It works, but when I am trying to assign the radial function value to multiquadric
it doesn't allow me to do so, due to syntax issue. For example:
using PyCall
interpolate = pyimport("scipy.interpolate")
x = [1,2,3,4,5]
y = [1,2,3,4,5]
z = [1,2,3,4,5]
rbf = interpolate.Rbf(x,y,z, function='multiquadric', smoothness=1.0)
for the above example I am getting this error:
LoadError: syntax: unexpected "="
Stacktrace:
[1] top-level scope
This is due to the use of function
variable. May I know what can be the way around this error, so that i can assign the multiquadric
radial for the rbf.
Look forward to the suggestions.
Thanks!!
Your problem is that
function
is a reserved keyword in Julia. Additionally, note that'string'
for strings is OK in Python but in Julia you have"string"
.The easiest workaround in your case is
py""
string macro:Now suppose you actually need at some point to pass
function=
parameter? It is not easy becausefunction
is a reserved keyword in Julia. What you could do is to pack it into a named tuple usingSymbol
notation:Now if you do:
than
myparam
would get unpacked to a keyword parameter.