[python-arrayfire] 03/11: FEAT: Adding new array properties

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu May 26 17:37:12 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 376135d368d4ff517a597aa27db759b7a2927a06
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Tue May 10 14:52:22 2016 -0400

    FEAT: Adding new array properties
    
    - Array.T now returns transpose
    - Array.H now returns hermitian transpose
    - Array.shape now returns shape
---
 arrayfire/array.py         | 21 +++++++++++++++++++++
 tests/simple/array_test.py |  3 +++
 2 files changed, 24 insertions(+)

diff --git a/arrayfire/array.py b/arrayfire/array.py
index 660baef..712c7ea 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -571,6 +571,20 @@ class Array(BaseArray):
         """
         return self.dtype().value
 
+    @property
+    def T(self):
+        """
+        Return the transpose of the array
+        """
+        return transpose(self, False)
+
+    @property
+    def H(self):
+        """
+        Return the hermitian transpose of the array
+        """
+        return transpose(self, False)
+
     def dims(self):
         """
         Return the shape of the array as a tuple.
@@ -584,6 +598,13 @@ class Array(BaseArray):
         dims = (d0.value,d1.value,d2.value,d3.value)
         return dims[:self.numdims()]
 
+    @property
+    def shape(self):
+        """
+        The shape of the array
+        """
+        return self.dims()
+
     def numdims(self):
         """
         Return the number of dimensions of the array.
diff --git a/tests/simple/array_test.py b/tests/simple/array_test.py
index 3a65e80..1aec934 100644
--- a/tests/simple/array_test.py
+++ b/tests/simple/array_test.py
@@ -18,6 +18,9 @@ def simple_array(verbose=False):
 
     a = af.Array([1, 2, 3])
     display_func(a)
+    display_func(a.T)
+    display_func(a.H)
+    print_func(a.shape)
 
     b = a.as_type(af.Dtype.s32)
     display_func(b)

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