[python-arrayfire] 26/58: BUGFIX: Fix conversion between numpy and arrayfire arrays

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Sep 28 13:57:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository python-arrayfire.

commit 2196fe51901095144ab33308d18076f441bfe377
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Sun Sep 11 02:16:51 2016 -0400

    BUGFIX: Fix conversion between numpy and arrayfire arrays
---
 arrayfire/interop.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/arrayfire/interop.py b/arrayfire/interop.py
index e512b75..4f5e39d 100644
--- a/arrayfire/interop.py
+++ b/arrayfire/interop.py
@@ -26,6 +26,18 @@ try:
 
     AF_NUMPY_FOUND=True
 
+    _nptype_to_aftype = {'f4' : Dtype.f32,
+                         'f8' : Dtype.f64,
+                         'b1' : Dtype.b8,
+                         'u1' : Dtype.u8,
+                         'i4' : Dtype.s32,
+                         's4' : Dtype.u32,
+                         'i8' : Dtype.s64,
+                         's8' : Dtype.u64,
+                         'c8' : Dtype.c32,
+                         'c16' : Dtype.c64}
+
+
     def np_to_af_array(np_arr):
         """
         Convert numpy.ndarray to arrayfire.Array.
@@ -41,7 +53,7 @@ try:
 
         in_shape = np_arr.shape
         in_ptr = np_arr.ctypes.data_as(ct.c_void_p)
-        in_dtype = np_arr.dtype.char
+        in_dtype = _nptype_to_aftype[np_arr.dtype.str[1:]]
 
         if (np_arr.flags['F_CONTIGUOUS']):
             return Array(in_ptr, in_shape, in_dtype)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-arrayfire.git



More information about the debian-science-commits mailing list