def test_epochs_subclass_slicing():
    "Subclassing Epochs should preserve the subclass after slicing"
    class Epochs_with_X(ts.Epochs):
        "An epoch class with extra 'stuff'"
        def total_duration(self):
            """Duration array for the epoch"""
            # XXX: bug in duration after slicing - attr_onread should be reset
            # after slicing
            #return self.duration.sum()
            return (self.start - self.stop).sum()

    time_0 = list(range(10))
    e = Epochs_with_X(time_0, duration=.2)
    npt.assert_equal(e.total_duration(), ts.TimeArray(2.0))

    slice_of_e = e[:5]
    npt.assert_equal(slice_of_e.total_duration(), ts.TimeArray(1.0))
    assert(slice_of_e.__class__ == Epochs_with_X)
dataset/ETHPy150Open nipy/nitime/nitime/tests/test_timeseries.py/test_epochs_subclass_slicing/swapped operands of `-`