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 "Andi Vajda (JIRA)" <ji...@apache.org> on 2013/12/10 14:51:12 UTC
[jira] [Resolved] (PYLUCENE-29) JCC: JArray('int') from integer
numpy ndarray not possible
[ https://issues.apache.org/jira/browse/PYLUCENE-29?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andi Vajda resolved PYLUCENE-29.
--------------------------------
Resolution: Cannot Reproduce
I installed numpy 1.8.0 via easy-install from pypi and I can't reproduce the issue. It works fine for me with jcc 2.18, python 2.7, Oracle Java 1.7 64 bits:
>>> import numpy as np
>>> from lucene import JArray, initVM
>>> initVM()
<jcc.JCCEnv object at 0x10029c138>
>>> a = np.asarray([1.,2.,3.]).astype(np.double)
>>> a
array([ 1., 2., 3.])
>>> JArray('double')(a)
JArray<double>[1.0, 2.0, 3.0]
>>> a = np.asarray([1,2,3]).astype(np.int0)
>>> JArray('int')(a)
JArray<int>[1, 2, 3]
>>> from lucene import JCC_VERSION
>>> JCC_VERSION
'2.18'
> 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)