Skip to content

Commit 376135d

Browse files
committed
FEAT: Adding new array properties
- Array.T now returns transpose - Array.H now returns hermitian transpose - Array.shape now returns shape
1 parent 7f3f844 commit 376135d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

arrayfire/array.py

+21
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,20 @@ def type(self):
571571
"""
572572
return self.dtype().value
573573

574+
@property
575+
def T(self):
576+
"""
577+
Return the transpose of the array
578+
"""
579+
return transpose(self, False)
580+
581+
@property
582+
def H(self):
583+
"""
584+
Return the hermitian transpose of the array
585+
"""
586+
return transpose(self, False)
587+
574588
def dims(self):
575589
"""
576590
Return the shape of the array as a tuple.
@@ -584,6 +598,13 @@ def dims(self):
584598
dims = (d0.value,d1.value,d2.value,d3.value)
585599
return dims[:self.numdims()]
586600

601+
@property
602+
def shape(self):
603+
"""
604+
The shape of the array
605+
"""
606+
return self.dims()
607+
587608
def numdims(self):
588609
"""
589610
Return the number of dimensions of the array.

tests/simple/array_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ def simple_array(verbose=False):
1818

1919
a = af.Array([1, 2, 3])
2020
display_func(a)
21+
display_func(a.T)
22+
display_func(a.H)
23+
print_func(a.shape)
2124

2225
b = a.as_type(af.Dtype.s32)
2326
display_func(b)

0 commit comments

Comments
 (0)