[python-arrayfire] 86/250: Add __array__ for easier numpy interoperability
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:34 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 31e023a1cde8f1705a01b208da784c0518e27b35
Author: Filipe Maia <filipe.c.maia at gmail.com>
Date: Tue Sep 1 15:38:52 2015 +0200
Add __array__ for easier numpy interoperability
---
arrayfire/array.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arrayfire/array.py b/arrayfire/array.py
index 2c827be..99967cf 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -499,6 +499,12 @@ class Array(BaseArray):
safe_call(backend.get().af_print_array(self.arr))
return '%s of dimensions %s' % (type(self), self.dims())
+ def __array__(self):
+ import numpy as np
+ res = np.empty(self.dims(), dtype=np.dtype(to_typecode[self.type()]), order='F')
+ safe_call(backend.get().af_get_data_ptr(ct.c_void_p(res.ctypes.data), self.arr))
+ return res
+
def display(a):
expr = inspect.stack()[1][-2]
if (expr is not None):
--
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