I would like to write a Python wrapper around the R library Rdtq (https://github.com/cran/Rdtq). That library (or rather, the class instance) takes as main inputs two functions: the drift f(x) and diffusion g(x). For instance,
my_drift = function(x) { -x }
my_diff = function(x) { rep(1,length(x)) }
Since I am writing a wrapper around the Rdtq class, I would like to pass the drift and diffusion function directly from Python, ideally via lambda function
my_python_drift(x) = lambda x: -x
my_python_diff(x) = lambda x: np.ones(len(x))
and so on. So more generally, my question is: Can I pass a Python lambda (or global) function as parameter to R, via rpy2?
lambda.