Exemple #1
0
async def test_chunks(range_n, n, expected):
    _chunks = []
    async for chunk in chunks(aiter(arange(range_n)), n):
        _chunks.append(chunk)
    assert _chunks == expected

    assert [c async for c in chunks(arange(range_n), n)] == expected
Exemple #2
0
async def test_arange():
    assert [x async for x in arange(10)] == list(range(10))
    assert [x async for x in arange(2, 10)] == list(range(2, 10))
    assert [x async for x in arange(0, 100, 10)] == list(range(0, 100, 10))

    assert 3 in arange(10)
    assert 3 not in arange(2)

    assert arange(10).count(1) == 1
    assert arange(10).index(3) == 3
Exemple #3
0
async def test_aslice():
    assert await alist(aslice(arange(100), 10)) == list(range(10))
    assert await alist(aslice(arange(100), 10, 20)) == list(range(10, 20))