4

I would like to use Clojure's Incanter, but I'd like to mix in calls to Python's extensive Numpy/Scipy numerical libraries. Is there an interoperability bridge between Incanter and Numpy that allows an embedded runtime of CPython to be run from Clojure and that interconverts Numpy's and Incanter's matrix data structures?

Jython isn't sufficient since Numpy requires CPython.

I am aware of (but have never used) http://jepp.sourceforge.net/, which allows Java programs to control an embedded CPython runtime -- but Numpy/Incanter matrix interconversion is still needed.

I'm looking for something similar to https://github.com/jolby/rincanter (which i have also not yet used) but for CPython/Numpy instead of R.

bshanks
  • 1,238
  • 2
  • 12
  • 24

1 Answers1

1

There is no ready-made numpy-incanter bridge. You have to write your own.

One way is to use the JNI resp. Jepp and - as you already said - convert raw ndarray bytes to something the Java Colt library can use (and vice versa; incanter builds on Colt). Additionally, you have wrap all functions you are interested in.

Another way would be to serialize the ndarrays and send them around between a CPython and a Jython (for example with Pyro, that works with CPython and Jython: http://packages.python.org/Pyro4/alternative.html#jython). Again you would have to translate the raw bytes into something Incanter resp. numpy can understand, but you could use Python code on the Java side without the need to wrap every single function in numpy/scipy with JNI.

Bernhard Kausler
  • 5,119
  • 3
  • 32
  • 36