Skip to content

Commit

Permalink
Update matrix.py
Browse files Browse the repository at this point in the history
- made get_row() and get_column() call the parent method when argument label was not a string
  • Loading branch information
jerela committed Nov 10, 2023
1 parent fde915b commit c130470
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions mola/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,11 @@ def get_column(self, c: str, as_list=True):
c -- str: label of the column
as_list - Boolean: whether to return the column as a list or not, in which case it is returned as a matrix (default true)
"""
idx = self.labels_cols.index(c)
return super().get_column(idx, as_list)
if isinstance(c,str):
idx = self.labels_cols.index(c)
return super().get_column(idx, as_list)
else:
return super().get_column(c, as_list)


def get_row(self, r: str, as_list=True):
Expand All @@ -1115,8 +1118,11 @@ def get_row(self, r: str, as_list=True):
r -- str: label of the row
as_list - Boolean: whether to return the row as a list or not, in which case it is returned as a matrix (default true)
"""
idx = self.labels_rows.index(r)
return super().get_row(idx, as_list)
if isinstance(r,str):
idx = self.labels_rows.index(r)
return super().get_row(idx, as_list)
else:
return super().get_row(r, as_list)


def __getitem__(self,label):
Expand Down

0 comments on commit c130470

Please sign in to comment.