diff --git a/neo/core/epoch.py b/neo/core/epoch.py index df3354578..b4aa1eb1a 100644 --- a/neo/core/epoch.py +++ b/neo/core/epoch.py @@ -179,6 +179,14 @@ def __getitem__(self, i): obj.labels = self.labels[i] return obj + def __getslice__(self, i, j): + ''' + Get a slice from :attr:`i` to :attr:`j`.attr[0] + + Doesn't get called in Python 3, :meth:`__getitem__` is called instead + ''' + return self.__getitem__(slice(i, j)) + @property def times(self): return pq.Quantity(self) diff --git a/neo/test/coretest/test_analogsignal.py b/neo/test/coretest/test_analogsignal.py index 56dd67870..c0f9e543e 100644 --- a/neo/test/coretest/test_analogsignal.py +++ b/neo/test/coretest/test_analogsignal.py @@ -431,7 +431,7 @@ def test__comparison_as_indexing_double_trace(self): def test__indexing_keeps_order_across_channels(self): # AnalogSignals with 10 traces each having 5 samples (eg. data[0] = [0,10,20,30,40]) data = np.array([range(10), range(10, 20), range(20, 30), range(30, 40), range(40, 50)]) - mask = np.full((5, 10), fill_value=False) + mask = np.full((5, 10), fill_value=False, dtype=bool) # selecting one entry per trace mask[[0, 1, 0, 3, 0, 2, 4, 3, 1, 4], range(10)] = True @@ -441,7 +441,7 @@ def test__indexing_keeps_order_across_channels(self): def test__indexing_keeps_order_across_time(self): # AnalogSignals with 10 traces each having 5 samples (eg. data[0] = [0,10,20,30,40]) data = np.array([range(10), range(10, 20), range(20, 30), range(30, 40), range(40, 50)]) - mask = np.full((5, 10), fill_value=False) + mask = np.full((5, 10), fill_value=False, dtype=bool) # selecting two entries per trace temporal_ids = [0, 1, 0, 3, 1, 2, 4, 2, 1, 4] + [4, 3, 2, 1, 0, 1, 2, 3, 2, 1] mask[temporal_ids, list(range(10)) + list(range(10))] = True diff --git a/neo/test/coretest/test_irregularysampledsignal.py b/neo/test/coretest/test_irregularysampledsignal.py index 89717c745..17e5d43c7 100644 --- a/neo/test/coretest/test_irregularysampledsignal.py +++ b/neo/test/coretest/test_irregularysampledsignal.py @@ -292,7 +292,7 @@ def test__comparison_as_indexing_multi_trace(self): def test__indexing_keeps_order_across_channels(self): # AnalogSignals with 10 traces each having 5 samples (eg. data[0] = [0,10,20,30,40]) data = np.array([range(10), range(10, 20), range(20, 30), range(30, 40), range(40, 50)]) - mask = np.full((5, 10), fill_value=False) + mask = np.full((5, 10), fill_value=False, dtype=bool) # selecting one entry per trace mask[[0, 1, 0, 3, 0, 2, 4, 3, 1, 4], range(10)] = True @@ -302,7 +302,7 @@ def test__indexing_keeps_order_across_channels(self): def test__indexing_keeps_order_across_time(self): # AnalogSignals with 10 traces each having 5 samples (eg. data[0] = [0,10,20,30,40]) data = np.array([range(10), range(10, 20), range(20, 30), range(30, 40), range(40, 50)]) - mask = np.full((5, 10), fill_value=False) + mask = np.full((5, 10), fill_value=False, dtype=bool) # selecting two entries per trace temporal_ids = [0, 1, 0, 3, 1, 2, 4, 2, 1, 4] + [4, 3, 2, 1, 0, 1, 2, 3, 2, 1] mask[temporal_ids, list(range(10)) + list(range(10))] = True