[python-arrayfire] 168/250: FEAT: Adding .as_type method to Array class

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:45 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 3f616eeeb5c2f24c67d51d0bc0a93808a5fc8c92
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Wed Dec 9 17:54:36 2015 -0500

    FEAT: Adding .as_type  method to Array class
---
 arrayfire/array.py         | 10 ++++++++++
 tests/simple/array_test.py |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/arrayfire/array.py b/arrayfire/array.py
index f1e7dcb..2b32213 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -423,6 +423,15 @@ class Array(BaseArray):
                 idims[n] = dims[n]
             self.arr = _create_empty_array(numdims, idims, to_dtype[type_char])
 
+    def as_type(self, ty):
+        """
+        Cast current array to a specified data type
+
+        Parameters
+        ----------
+        ty : Return data type
+        """
+        return cast(self, ty)
 
     def copy(self):
         """
@@ -1134,3 +1143,4 @@ def read_array(filename, index=None, key=None):
     return out
 
 from .algorithm import sum
+from .arith import cast
diff --git a/tests/simple/array_test.py b/tests/simple/array_test.py
index d7652b5..32c0420 100644
--- a/tests/simple/array_test.py
+++ b/tests/simple/array_test.py
@@ -18,6 +18,10 @@ def simple_array(verbose=False):
 
     a = af.Array([1, 2, 3])
     display_func(a)
+
+    b = a.as_type(af.Dtype.s32)
+    display_func(b)
+
     print_func(a.elements(), a.type(), a.dims(), a.numdims())
     print_func(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
     print_func(a.is_complex(), a.is_real(), a.is_double(), a.is_single())

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