embedPy icon indicating copy to clipboard operation
embedPy copied to clipboard

numpy array returns as foreign

Open estradajke opened this issue 3 years ago • 5 comments

Hi. I am unable to return a numpy array as anything but foreign. Am I missing some syntax to force the conversion? I've downloaded the latest embedPy files and running a recent version of kdb and python.

user@box ~ % q KDB+ 4.0 2021.07.12 Copyright (C) 1993-2021 Kx Systems m64/ 8(16)core 65536MB user box 127.0.0.1 EXPIRE 2022.10.04 [email protected] KOD #5005939

q)\l p.q q)sys:.p.importsys;sys[:version] "3.10.1 (v3.10.1:2cd268a3a9, Dec 6 2021, 14:28:59) [Clang 13.0.0 (clang-1300.. q).p.set[x;3];.p.get[x] 3 q)np:.p.importnumpy;arange:np:arange;arange[12]` foreign

estradajke avatar Jan 24 '22 19:01 estradajke

Just noticed the formatting was unclear.

q)\l p.q

q)sys:.p.importsys;sys[:version] "3.10.1 (v3.10.1:2cd268a3a9, Dec 6 2021, 14:28:59) [Clang 13.0.0 (clang-1300..

q).p.set[x;3];.p.get[x] 3

q)np:.p.importnumpy;arange:np:arange;arange[12]` foreign

estradajke avatar Jan 25 '22 19:01 estradajke

Hi,

It looks to be an issue with either the use of Python 3.10 or an update to numpy.

Can you provide the version of numpy that you're using please and we'll aim to take a look.

Conor

cmccarthy1 avatar Jan 25 '22 22:01 cmccarthy1

Thanks for the quick reply Conor. It's 1.22.1. I'm happy to move to another recent version if that helps.

q)np:.p.import[numpy];np[:version]` "1.22.1"

estradajke avatar Jan 26 '22 19:01 estradajke

I've confirmed it's the numpy version that is the issue, it looks like the underlying representation at the C level has changed somewhat which we'll need to investigate. If you downgrade numpy to <1.22 the behaviour should resolve itself, at the present time there isn't an explicit workaround

cmccarthy1 avatar Jan 26 '22 19:01 cmccarthy1

Rolled back to 1.21.

q)arange[12]` 0 1 2 3 4 5 6 7 8 9 10 11

Thanks!

estradajke avatar Jan 26 '22 21:01 estradajke