[python-arrayfire] 110/250: BUGFIX: indexing with boolean arrays

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:37 UTC 2016


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

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

commit 2a524630035cf360ecb249abfbaacdeb25096d33
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Tue Sep 8 13:33:53 2015 -0400

    BUGFIX: indexing with boolean arrays
---
 arrayfire/index.py    | 16 +++++++++++++++-
 tests/simple_index.py |  7 +++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/arrayfire/index.py b/arrayfire/index.py
index 0388d0c..e3dca65 100644
--- a/arrayfire/index.py
+++ b/arrayfire/index.py
@@ -192,10 +192,24 @@ class Index(ct.Structure):
         self.isSeq   = True
 
         if isinstance(idx, BaseArray):
-            self.idx.arr = idx.arr
+
+            arr = ct.c_void_p(0)
+
+            if (Enum_value(idx.dtype()) ==
+                Enum_value(Dtype.b8)):
+                safe_call(backend.get().af_where(ct.pointer(arr), idx.arr))
+            else:
+                safe_call(backend.get().af_retain_array(ct.pointer(arr), idx.arr))
+
+            self.idx.arr = arr
             self.isSeq   = False
         elif isinstance(idx, ParallelRange):
             self.idx.seq = idx
             self.isBatch = True
         else:
             self.idx.seq = Seq(idx)
+
+    # def __del__(self):
+    #     if not self.isSeq:
+    #         arr = self.idx.arr
+    #         backend.get().af_release_array(arr)
diff --git a/tests/simple_index.py b/tests/simple_index.py
index bb87cf3..b7100f4 100755
--- a/tests/simple_index.py
+++ b/tests/simple_index.py
@@ -66,3 +66,10 @@ af.display(b)
 for r in rows:
     af.display(r)
     af.display(b[:,r])
+
+a = af.randu(3)
+c = af.randu(3)
+b = af.constant(1,3,dtype=af.Dtype.b8)
+af.display(a)
+a[b] = c
+af.display(a)

-- 
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