Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerapritchard committed Apr 29, 2024
1 parent 2782d54 commit c76447c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/tssc/MASTSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,28 @@ def _repr_html_(self):
return "No results found"
else:
return "I am an uninitialized MASTSearch result"


def __getitem__(self, key):
# TODO: Look into class mixins & pandas for this?
strlist = False
intlist = False
if(isinstance(key, list)):
if(all(isinstance(n, int) for n in key)):
if isinstance(key, list):
if all(isinstance(n, int) for n in key):
intlist = True
if(all(isinstance(n, str) for n in key)):
if all(isinstance(n, str) for n in key):
strlist = True

if isinstance(key, (slice, int)) or (intlist):
if(not intlist):
mask = np.in1d(np.arange(len(self.table)), np.arange(len(self.table))[key])
if not intlist:
mask = np.in1d(
np.arange(len(self.table)), np.arange(len(self.table))[key]
)
else:
mask = np.in1d(self.table.index, key)
return self._mask(mask)
if (isinstance(key, (str, pd.Series)) or strlist):
if isinstance(key, (str, pd.Series)) or strlist:
# Return a column as a series, or a dataframe of columns
# Note that we're not returning a Search Object here as
# Note that we're not returning a Search Object here as
# we havce additional Requiered columns, etc.
return self.table[key]
if hasattr(key, "__iter__"):
Expand Down

0 comments on commit c76447c

Please sign in to comment.