def test_zip_literals(): a = Stream() b = Stream() c = sz.zip(a, 123, b) L = c.sink_to_list() a.emit(1) b.emit(2) assert L == [(1, 123, 2)] a.emit(4) b.emit(5) assert L == [(1, 123, 2), (4, 123, 5)]
def test_zip_timeout(): a = Stream(asynchronous=True) b = Stream(asynchronous=True) c = sz.zip(a, b, maxsize=2) L = c.sink_to_list() a.emit(1) a.emit(2) future = a.emit(3) with pytest.raises(gen.TimeoutError): yield gen.with_timeout(timedelta(seconds=0.01), future) b.emit('a') yield future assert L == [(1, 'a')]
def test_zip(): a = Stream() b = Stream() c = sz.zip(a, b) L = c.sink_to_list() a.emit(1) b.emit('a') a.emit(2) b.emit('b') assert L == [(1, 'a'), (2, 'b')] d = Stream() # test zip from the object itself # zip 3 streams together e = a.zip(b, d) L2 = e.sink_to_list() a.emit(1) b.emit(2) d.emit(3) assert L2 == [(1, 2, 3)]
def gather_inputs(self, inputs): return streamz.zip(*inputs).filter(lambda x: x[-1]).map(lambda x: x[:-1])
def gather_inputs(self, inputs): return streamz.zip(*inputs)