From c76447c29ce1b83152ab263442b2f1db6eed438c Mon Sep 17 00:00:00 2001 From: Tyler Pritchard Date: Mon, 29 Apr 2024 13:11:16 -0400 Subject: [PATCH] ruff --- src/tssc/MASTSearch.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/tssc/MASTSearch.py b/src/tssc/MASTSearch.py index caf80ef..476294a 100644 --- a/src/tssc/MASTSearch.py +++ b/src/tssc/MASTSearch.py @@ -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__"):