Has anyone tried wrapping C++ code, using the stan-math library, for use in Python? I’d appreciate any help or advice.

I’ve been relatively successful using the library from within R, thanks to Tobias Madsen’s blog post. But I’d really like to use it in Python.

I tried using cython and the eigency library. It compiles, and I’m able to pass my function a numpy array and some parameter values. But it doesn’t give me the same answer as that from my c++ test code.

If you are curious, the code is up on github:

https://github.com/sjvrensburg/eigency_stan_problem

But I’ll try and produce a more manageable, minimal working example later in the week.

I also tried pybind11 with the C++11 branch of stan-maths, but I had even less success with that.

I am new to C++ and I haven’t really used cython or pybind11 before. Any pointers would be most appreciated.