[ https://issues.apache.org/jira/browse/PYLUCENE-29?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13844285#comment-13844285 ]
Martin Scherer commented on PYLUCENE-29: ---------------------------------------- I've upgraded my numpy installation to 1.8.0 and now it works like a charm! > JCC: JArray('int') from integer numpy ndarray not possible > ---------------------------------------------------------- > > Key: PYLUCENE-29 > URL: https://issues.apache.org/jira/browse/PYLUCENE-29 > Project: PyLucene > Issue Type: Bug > Environment: JCC-2.18, numpy-1.7.1, Java-1.7.0.25, Linux 64Bit > Reporter: Martin Scherer > Labels: jcc > > One can properly directly convert numpy double arrays to JArrays, but numpy > integer arrays have to be converted to a Python list before. Else one would > receive a type error. The following code snippet shows the error: > ###### > import numpy as np > from emma2.util.pystallone import JArray, initVM > if __name__ == '__main__': > a = np.asarray([1.,2.,3.]).astype(np.double) > print a > print JArray('double')(a) > a = np.asarray([1,2,3]).astype(np.int0) > print JArray('int')(a) > ##### > Output: > [ 1. 2. 3.] > JArray<double>[1.0, 2.0, 3.0] > Traceback (most recent call last): > File "minimal_example_int_convert_fails.py", line 14, in <module> > print JArray('int')(a) > TypeError: 1 > But this works: > JArray('int')(a.tolist()) > Since I did not manage to figure out this behaviour, I'am filing this issue. > If it has a simple solution please let me know and close this one. > Thanks in advance, > Best - Martin -- This message was sent by Atlassian JIRA (v6.1.4#6159)