コード例 #1
0
ファイル: test_core.py プロジェクト: masums/streamz
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)]
コード例 #2
0
ファイル: test_core.py プロジェクト: zjw0358/streamz3
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')]
コード例 #3
0
ファイル: test_core.py プロジェクト: zjw0358/streamz3
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)]
コード例 #4
0
 def gather_inputs(self, inputs):
     return streamz.zip(*inputs).filter(lambda x: x[-1]).map(lambda x: x[:-1])
コード例 #5
0
 def gather_inputs(self, inputs):
     return streamz.zip(*inputs)