pynapple-org / pynapple

PYthon Neural Analysis Package :pineapple:
https://pynapple-org.github.io/pynapple/
MIT License
243 stars 59 forks source link

IntervalSet type change on logical slicing #260

Closed jolson1129 closed 2 months ago

jolson1129 commented 3 months ago

While using an interval set, logical slicing appears to transform the IntervalSet into a numpy array.

gviejo commented 2 months ago

Can you give an example?

jolson1129 commented 2 months ago

I've found that a list of booleans is okay - I had a pandas series in this case when I observed this behavior.

import pynapple as nap
import pandas as pd

is_simp = nap.IntervalSet(start=[0,3], end=[1,4])
bool_series = pd.Series([True, False])
print(type(is_simp[1]))
print(type(is_simp[[True, False]]))
print(type(is_simp[bool_series]))

Output: <class 'pynapple.core.interval_set.IntervalSet'> <class 'pynapple.core.interval_set.IntervalSet'> <class 'numpy.ndarray'>

gviejo commented 2 months ago

Ok I see. Doesn't seem too complicated to fix.

gviejo commented 2 months ago

Fixed