You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Numpy Interoperability Issues with certain datatypes #92
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 arrayfireaf.interop.np_to_af_array# arrayfire to numpyaf.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!
Activity
pavanky commentedon Sep 11, 2016
Hmm this is weird. This works just fine on Linux..
pavanky commentedon Sep 11, 2016
@lukasbindreiter This is fixed in devel