Esempio n. 1
0
def test_reproducible_indexing():
    i = Indexer(1e6, seed=12345)
    a = [next(i) for _ in range(10)]
    i = Indexer(1e6, seed=12345)
    b = [next(i) for _ in range(10)]
    assert a == b
    assert a != list(range(10))
Esempio n. 2
0
def test_sequential_reset():
    i = Indexer(1e6, seed='sequential')
    a = [next(i) for _ in range(10)]
    assert a == list(range(10))
    assert i.count == 10
    assert i.index == 9

    i.reset_sequential_indices()
    assert i.count == i.index == 0

    a = [next(i) for _ in range(10)]
    assert a == list(range(10))
    assert i.count == 10
    assert i.index == 9
Esempio n. 3
0
def test_seed():
    i = Indexer(1e6)
    assert i.seed_value is None
    i = Indexer(1e6, seed=42)
    assert i.seed_value == 42
Esempio n. 4
0
def test_index_attribute():
    i = Indexer(1e6)
    assert i.index is None
    for index in range(10):
        next(i)
        assert i.index != i.count
Esempio n. 5
0
def test_count():
    i = Indexer(1e6)
    for index in range(10):
        assert i.count == index
        next(i)
Esempio n. 6
0
def test_sequential_seed():
    i = Indexer(1e6, seed='sequential')
    a = [next(i) for _ in range(10)]
    assert a == list(range(10))
    assert i.count == 10
    assert i.index == 9
Esempio n. 7
0
def test_no_seed_different_each_time():
    i = Indexer(1e6)
    a = [next(i) for _ in range(10)]
    b = list(range(10))
    assert a != b
    assert len(set(a)) == 10
Esempio n. 8
0
def test_sequential_wraparound():
    i = Indexer(5, 'sequential')
    assert [next(i) for _ in range(10)] == list(range(5)) * 2
Esempio n. 9
0
def test_ncols():
    i = Indexer(1e6)
    assert i.ncols == 1e6