Ejemplo n.º 1
0
def test_spawn_equiv():
    ss = SeedSequence(0)
    children = ss.spawn(2)
    direct = [
        SeedSequence(0, spawn_key=(0, )),
        SeedSequence(0, spawn_key=(1, ))
    ]
    assert len(children) == 2
    for c, d in zip(children, direct):
        assert_array_equal(c.generate_state(4), d.generate_state(4))
Ejemplo n.º 2
0
def test_against_numpy_spawn():
    entropy = [
        1231854054, 2485020620, 2472030289, 641337343, 3981837114, 248869471,
        532471113, 949593482, 1224833511, 2864447214
    ]
    ss = SeedSequence(entropy)
    np_ss = NPSeedSequence(entropy)
    ss_children = ss.spawn(2)
    np_ss_children = np_ss.spawn(2)
    assert ss.n_children_spawned == np_ss.n_children_spawned
    for child, np_child in zip(ss_children, np_ss_children):
        assert_array_equal(child.generate_state(10),
                           np_child.generate_state(10))
Ejemplo n.º 3
0
def test_state():
    ss = SeedSequence(0)
    assert "entropy" in ss.state
    assert ss.state["entropy"] == 0
    assert "n_children_spawned" in ss.state
    assert ss.state["n_children_spawned"] == 0
    assert "pool_size" in ss.state
    assert ss.state["pool_size"] == 4

    for key in "spawn_key":
        assert key not in ss.state
    children = ss.spawn(10)
    assert ss.state["n_children_spawned"] == 10

    assert "spawn_key" in children[0].state
    assert children[0].state["spawn_key"] == (0, )

    ss = SeedSequence(0, pool_size=8)
    assert "pool_size" in ss.state
    assert ss.state["pool_size"] == 8