Skip to content

Commit a6ea957

Browse files
committed
Added native Slicing and Indexing support
1 parent 2323ff9 commit a6ea957

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pyrix/matrix/Matrix.py

+16
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,22 @@ def __getattr__(self, name):
205205

206206
def __delattr__(self, name):
207207
del self.__dict__[name]
208+
209+
def __getitem__(self,key):
210+
if(isinstance(key, int)):
211+
return self.matrix.data[key]
212+
if(isinstance(key,(list,tuple)) and len(key)==2):
213+
return self.matrix.data[key[0]][key[1]]
214+
else:
215+
print("MultiDimensional Matrix in Works")
216+
217+
def __setitem__(self,key,value):
218+
if(isinstance(key, int)):
219+
self.matrix.data[key]=value
220+
if(isinstance(key,(list,tuple)) and len(key)==2):
221+
self.matrix.data[key[0]][key[1]]=value
222+
else:
223+
print("MultiDimensional Matrix in Works")
208224
# *------- Basic Operations on Matrices -----------------------------------*
209225

210226
# *------- Add Matrix -----------------------------------------------------*

0 commit comments

Comments
 (0)