MCPcopy Create free account
hub / github.com/numpy/numpy / test_jumped

Function test_jumped

numpy/random/tests/test_generator_mt19937.py:2612–2636  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

2610
2611@pytest.mark.parametrize("config", JUMP_TEST_DATA)
2612def test_jumped(config):
2613 # Each config contains the initial seed, a number of raw steps
2614 # the sha256 hashes of the initial and the final states' keys and
2615 # the position of the initial and the final state.
2616 # These were produced using the original C implementation.
2617 seed = config["seed"]
2618 steps = config["steps"]
2619
2620 mt19937 = MT19937(seed)
2621 # Burn step
2622 mt19937.random_raw(steps)
2623 key = mt19937.state["state"]["key"]
2624 if sys.byteorder == 'big':
2625 key = key.byteswap()
2626 sha256 = hashlib.sha256(key)
2627 assert mt19937.state["state"]["pos"] == config["initial"]["pos"]
2628 assert sha256.hexdigest() == config["initial"]["key_sha256"]
2629
2630 jumped = mt19937.jumped()
2631 key = jumped.state["state"]["key"]
2632 if sys.byteorder == 'big':
2633 key = key.byteswap()
2634 sha256 = hashlib.sha256(key)
2635 assert jumped.state["state"]["pos"] == config["jumped"]["pos"]
2636 assert sha256.hexdigest() == config["jumped"]["key_sha256"]
2637
2638
2639def test_broadcast_size_error():

Callers

nothing calls this directly

Calls 1

byteswapMethod · 0.80

Tested by

no test coverage detected