NumPy arrays and Pythonika
Ero Carrera (ero) <erocarreragmailcom> Thursday, November 16 2006 19:21.00 CST


If someone tries to pass NumPys ndarray objects into Mathematica with something like:

Py["numpy.array([[1,2,3],[4,5,6],[7,8,9]])"]

the following error will appear:

Object type cant be converted!

Thats due to the fact that Pythonika doesnt know what to do when finding objects of such type (or any type that its not one of Pythons basic types).

In order to get around that, one can do something like:

Py["numpy.array([[1,2,3],[4,5,6],[7,8,9]]).tolist()"]

Which will return the expected nested lists in Mathematica:

{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

Comments
Posted: Wednesday, December 31 1969 18:00.00 CST