[python-arrayfire] 131/250: Fixing af.display to take precision digits as parameter

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:40 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 4a59387e13926db4f644c124133017bfd9706b58
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Tue Nov 10 09:58:14 2015 -0500

    Fixing af.display to take precision digits as parameter
---
 arrayfire/array.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arrayfire/array.py b/arrayfire/array.py
index c971e2c..79a6a4d 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -182,7 +182,7 @@ def _get_assign_dims(key, idims):
     elif isinstance(key, ParallelRange):
         dims[0] = _slice_to_length(key.S, idims[0])
         return dims
-    elif isinstance(key, BaseArray):        
+    elif isinstance(key, BaseArray):
         # If the array is boolean take only the number of nonzeros
         if(key.dtype() is Dtype.b8):
             dims[0] = int(sum(key))
@@ -1039,7 +1039,7 @@ class Array(BaseArray):
         safe_call(backend.get().af_get_data_ptr(ct.c_void_p(res.ctypes.data), self.arr))
         return res
 
-def display(a):
+def display(a, precision=4):
     """
     Displays the contents of an array.
 
@@ -1047,16 +1047,20 @@ def display(a):
     ----------
     a : af.Array
         Multi dimensional arrayfire array
+    precision: int. optional.
+        Specifies the number of precision bits to display
     """
     expr = inspect.stack()[1][-2]
+    name = ""
 
     try:
         if (expr is not None):
             st = expr[0].find('(') + 1
             en = expr[0].rfind(')')
-            print('%s' % expr[0][st:en])
-        safe_call(backend.get().af_print_array(a.arr))
+            name = expr[0][st:en]
     except:
-        safe_call(backend.get().af_print_array(a.arr))
+        pass
+
+    safe_call(backend.get().af_print_array_gen(name, a.arr, ct.c_int(precision)))
 
 from .algorithm import sum

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