MCPcopy Index your code
hub / github.com/numpy/numpy / test_jumped

Function test_jumped

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

Source from the content-addressed store, hash-verified

2654
2655@pytest.mark.parametrize("config", JUMP_TEST_DATA)
2656def test_jumped(config):
2657 # Each config contains the initial seed, a number of raw steps
2658 # the sha256 hashes of the initial and the final states' keys and
2659 # the position of the initial and the final state.
2660 # These were produced using the original C implementation.
2661 seed = config["seed"]
2662 steps = config["steps"]
2663
2664 mt19937 = MT19937(seed)
2665 # Burn step
2666 mt19937.random_raw(steps)
2667 key = mt19937.state["state"]["key"]
2668 if sys.byteorder == 'big':
2669 key = key.byteswap()
2670 sha256 = hashlib.sha256(key)
2671 assert mt19937.state["state"]["pos"] == config["initial"]["pos"]
2672 assert sha256.hexdigest() == config["initial"]["key_sha256"]
2673
2674 jumped = mt19937.jumped()
2675 key = jumped.state["state"]["key"]
2676 if sys.byteorder == 'big':
2677 key = key.byteswap()
2678 sha256 = hashlib.sha256(key)
2679 assert jumped.state["state"]["pos"] == config["jumped"]["pos"]
2680 assert sha256.hexdigest() == config["jumped"]["key_sha256"]
2681
2682
2683def test_broadcast_size_error():

Callers

nothing calls this directly

Calls 1

byteswapMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…