Skip to content

Commit

Permalink
NeuronList indexer: fix issue when key is pd.Series with non-range index
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Mar 4, 2025
1 parent b2d8c7b commit fe544a3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions navis/core/neuronlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ def __deepcopy__(self):

def __getitem__(self, key):
if utils.is_iterable(key):
# This avoids issues when the Series' index is not [0, 1, 2, etc]
if isinstance(key, pd.Series):
key = key.values

if all([isinstance(k, (bool, np.bool_)) for k in key]):
if len(key) != len(self.neurons):
raise IndexError('boolean index did not match indexed '
Expand Down

0 comments on commit fe544a3

Please sign in to comment.