[python-arrayfire] 53/250: Raise exceptions when calling array.to_* if array is empty

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:30 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 58e030a24d9caf26c77ce3fa39272aabef5bf7df
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Wed Aug 12 13:06:53 2015 -0400

    Raise exceptions when calling array.to_* if array is empty
---
 arrayfire/array.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arrayfire/array.py b/arrayfire/array.py
index d5c7da8..eaae325 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -453,6 +453,10 @@ class array(base_array):
             raise IndexError(str(e))
 
     def to_ctype(self, row_major=False, return_shape=False):
+
+        if (self.arr.value == 0):
+            raise RuntimeError("Can not call to_ctype on empty array")
+
         tmp = transpose(self) if row_major else self
         ctype_type = to_c_type[self.type()] * self.elements()
         res = ctype_type()
@@ -463,6 +467,10 @@ class array(base_array):
             return res
 
     def to_array(self, row_major=False, return_shape=False):
+
+        if (self.arr.value == 0):
+            raise RuntimeError("Can not call to_array on empty array")
+
         res = self.to_ctype(row_major, return_shape)
 
         host = __import__("array")

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