Skip to content

Commit

Permalink
Added native Slicing and Indexing support
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhi-1U committed Dec 22, 2020
1 parent 2323ff9 commit a6ea957
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pyrix/matrix/Matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ def __getattr__(self, name):

def __delattr__(self, name):
del self.__dict__[name]

def __getitem__(self,key):
if(isinstance(key, int)):
return self.matrix.data[key]
if(isinstance(key,(list,tuple)) and len(key)==2):
return self.matrix.data[key[0]][key[1]]
else:
print("MultiDimensional Matrix in Works")

def __setitem__(self,key,value):
if(isinstance(key, int)):
self.matrix.data[key]=value
if(isinstance(key,(list,tuple)) and len(key)==2):
self.matrix.data[key[0]][key[1]]=value
else:
print("MultiDimensional Matrix in Works")
# *------- Basic Operations on Matrices -----------------------------------*

# *------- Add Matrix -----------------------------------------------------*
Expand Down

0 comments on commit a6ea957

Please sign in to comment.