You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-dev@lucene.apache.org by "Martin Scherer (JIRA)" <ji...@apache.org> on 2013/12/10 13:51:09 UTC
[jira] [Created] (PYLUCENE-29) JCC: JArray('int') from integer
numpy ndarray not possible
Martin Scherer created PYLUCENE-29:
--------------------------------------
Summary: 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
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)