Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy Interoperability Issues with certain datatypes #92

Closed
lukasbindreiter opened this issue Sep 6, 2016 · 2 comments
Closed

Numpy Interoperability Issues with certain datatypes #92

lukasbindreiter opened this issue Sep 6, 2016 · 2 comments
Milestone

Comments

@lukasbindreiter
Copy link

lukasbindreiter commented Sep 6, 2016

There appears to be some issue regarding the interoperability between numpy and arrayfire-python regarding certain data types.
I did the conversion using the methods:

# numpy to arrayfire
af.interop.np_to_af_array

# arrayfire to numpy
af.Array.__array__()

The only two data types which appear to work as intended are float and double (f32 and f64 in Arrayfire, np.float32 and np.float64 in numpy).

64 bit integer values (signed and unsigned) and bool appear to be not supported (KeyError when trying to convert), but the data types u8, u32 and s32 are not converted correctly.

An example:

nparr = np.array([5, 10, 15, 20, 25, 30], np.int)
print(nparr)
# Output: [ 5 10 15 20 25 30]

afarr = af.interop.np_to_af_array(nparr)
print(afarr)
# Output:
# arrayfire.Array()
# Type: long int
# [6 1 1 1]
#42949672965 
#85899345935 
#128849018905 
# -7780732514909268839 
#0
#0

afarr += 10
print(afarr.__array__())
# Output: [25 10 35 20 45 30] instead of [25, 30, 35, 40, 45, 50]
# Ten was only added to every second value!

I tried these conversions with all of the aforementioned datatypes

I am using ArrayFire v3.3.2 (build f65dd97) with Python 3.5.2 on 64bit Windows

@pavanky
Copy link
Member

pavanky commented Sep 11, 2016

Hmm this is weird. This works just fine on Linux..

@pavanky pavanky mentioned this issue Sep 11, 2016
@pavanky
Copy link
Member

pavanky commented Sep 11, 2016

@lukasbindreiter This is fixed in devel

@pavanky pavanky added this to the 3.4 milestone Sep 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants