def test_compress_signals(self): workflow = self.scheme link = workflow.links[0] self.assertSequenceEqual(compress_signals([]), []) signals_in = [ Signal(link, 1, None), Signal(link, 3, None), Signal(link, 2, None), ] self.assertSequenceEqual(compress_signals(signals_in), signals_in[-1:]) signals_in = [ Signal(link, None, None), Signal(link, 3, None), Signal(link, 2, None), ] self.assertSequenceEqual(compress_signals(signals_in), [signals_in[0], signals_in[-1]]) signals_in = [ Signal(link, None, 1), Signal(link, 3, 1), Signal(link, 2, 2), ] self.assertSequenceEqual( compress_signals(signals_in), signals_in, ) signals_in = [ Signal(link, 1, 1), Signal(link, None, 1), Signal(link, 2, 2), ] self.assertSequenceEqual( compress_signals(signals_in), signals_in[1:], )
def test_compress_signals(self): workflow = self.scheme link = workflow.links[0] self.assertSequenceEqual(compress_signals([]), []) signals_in = [ Signal(link, 1, None), Signal(link, 3, None), Signal(link, 2, None), ] self.assertSequenceEqual( compress_signals(signals_in), signals_in[-1:] ) signals_in = [ Signal(link, None, None), Signal(link, 3, None), Signal(link, 2, None), ] self.assertSequenceEqual( compress_signals(signals_in), [signals_in[0], signals_in[-1]] ) signals_in = [ Signal(link, None, 1), Signal(link, 3, 1), Signal(link, 2, 2), ] self.assertSequenceEqual( compress_signals(signals_in), signals_in, ) signals_in = [ Signal(link, 1, 1), Signal(link, None, 1), Signal(link, 2, 2), ] self.assertSequenceEqual( compress_signals(signals_in), signals_in[1:], )
def test_compress_signals_typed(self): l1, l2 = self.scheme.links[0], self.scheme.links[1] New, Update, Close = Signal.New, Signal.Update, Signal.Close signals = [ New(l1, 1, index=0), Update(l1, 2, index=0), New(l2, "a", index=0), Update(l2, 2, index=0), Close(l1, None, index=1), New(l1, None, index=1), Update(l2, "b", index=0) ] # must preserve relative order of New/Close self.assertSequenceEqual( compress_signals(signals), [ New(l1, 1, index=0), New(l2, "a", index=0), Close(l1, None, index=1), New(l1, None, index=1), Update(l2, "b", index=0) ], ) signals = [ Update(l1, 2, index=0), New(l2, "a", index=0), Update(l2, 2, index=0), Close(l1, None, index=1), ] self.assertSequenceEqual( compress_signals(signals), [ New(l2, "a", index=0), Update(l2, 2, index=0), Close(l1, None, index=1), ], )
def compress_signals(self, signals): """ Reimplemented from :func:`SignalManager.compress_signals`. """ return compress_signals(signals)
def compress_signals(self, signals): """ Reimplemented from :func:`SignalManager.compress_signals`. """ return compress_signals(signals)