Skip to content

Commit

Permalink
FEAT: Adding new array properties
Browse files Browse the repository at this point in the history
- Array.T now returns transpose
- Array.H now returns hermitian transpose
- Array.shape now returns shape
  • Loading branch information
pavanky committed May 10, 2016
1 parent 7f3f844 commit 376135d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions arrayfire/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,20 @@ def type(self):
"""
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.
Expand All @@ -584,6 +598,13 @@ def dims(self):
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.
Expand Down
3 changes: 3 additions & 0 deletions tests/simple/array_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 376135d

Please sign in to comment.