KxSystems / embedPy

Allows the kdb+ interpreter to call Python functions
https://code.kx.com/q/interfaces
Apache License 2.0
87 stars 42 forks source link

numpy array conversion to q #62

Closed ghlian closed 5 years ago

ghlian commented 5 years ago

in python 3.7 and numpy 1.15.2, q version 3.6 64bit the numpy array cannot be converted to q data.

all the testcases return 0

t[12]~np[:arange][*][12.] t[12]~np[:arange;*][12.] t[12]~np[:arange][*;12.] t[12]~np[:arange;*;12.] t[12]~np[:arange][12.] t[12]~np[:arange;12.]

t[12]~np[:arange][<]12. t[12]~np[:arange;<]12. t[12]~np[:arange][<;12.] t[12]~np[:arange;<;12.]

t[12]~.p.py2q np[:arange][>]12. t[12]~.p.py2q np[:arange;>]12. t[12]~.p.py2q np[:arange][>;12.] t[12]~.p.py2q np[:arange;>;12.]

ghlian commented 5 years ago

t[12]~np[:arange][*][12.] t[12]~np[:arange;*][12.] t[12]~np[:arange][*;12.] t[12]~np[:arange;*;12.] t[12]~np[:arange][12.] t[12]~np[:arange;12.]

ghlian commented 5 years ago

used the test cases. the symbol is not shown in this post above t[12]~np[:arange][*][12.] get 0b

Dianeod commented 5 years ago

Hi,

Could you please provide the code for what t is?

If t[12] is equivalent to the q function q)til 12 then the following should rectify the problem:

q)t:{til x}

q)t[12]~(np[:arange;*][12]) 1b

Thanks, Diane

ghlian commented 5 years ago

the codes are simply the testcases in embedPy/tests/syntax.t

All return 0b. q)t[12] is working fine.

ghlian commented 5 years ago

however, in numpy 1.14.3 and q version 3.5 64bit, all the testcases return 1b.

jhanna-kx commented 5 years ago

Hi, I think there are were some issues with backticks "`" disappearing in the markdown.

I haven't been able to replicate this so far using the latest version of embedPy and kdb+ 3.6 on any of linux, macOS or windows.

Can you let us a few more details so we can try and replicate your issue.

Below is what I get by building from the latest version of the source (on linux in this case)

$ conda list numpy && conda list python
# packages in environment at /home/james/anaconda3/envs/py37:
#
# Name                    Version                   Build  Channel
numpy                     1.15.2           py37h1d66e8a_1  
numpy-base                1.15.2           py37h81de0dd_1  
# packages in environment at /home/james/anaconda3/envs/py37:
#
# Name                    Version                   Build  Channel
python                    3.7.0                hc3d631a_0  
$ q p.q
KDB+ 3.6 2018.06.01 Copyright (C) 1993-2018 Kx Systems
l64/ 8()core 64303MB ...

q)np:.p.import`numpy
q)t:"f"$til@
q)t[12]~np[`:arange][*][12.]`
1b
q)t[12]~np[`:arange;*][12.]`
1b
q)t[12]~np[`:arange][*;12.]`
1b
q)t[12]~np[`:arange;*;12.]`
1b
q)t[12]~np[`:arange][12.]`
1b
q)t[12]~np[`:arange;12.]`
1b
q)t[12]~np[`:arange][<]12.
1b
q)t[12]~np[`:arange;<]12.
1b
q)t[12]~np[`:arange][<;12.]
1b
q)t[12]~np[`:arange;<;12.]
1b
q)
elopezaguilera commented 5 years ago

Closing this issue. We have been able to replicate the issue with the provided info. Feel free to reopen with details so that we can replicate the issue.