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

Function test_reference_data

numpy/random/tests/test_seed_sequence.py:7–54  ·  view source on GitHub ↗

Check that SeedSequence generates data the same as the C++ reference. https://gist.github.com/imneme/540829265469e673d045

()

Source from the content-addressed store, hash-verified

5
6
7def test_reference_data():
8 """ Check that SeedSequence generates data the same as the C++ reference.
9
10 https://gist.github.com/imneme/540829265469e673d045
11 """
12 inputs = [
13 [3735928559, 195939070, 229505742, 305419896],
14 [3668361503, 4165561550, 1661411377, 3634257570],
15 [164546577, 4166754639, 1765190214, 1303880213],
16 [446610472, 3941463886, 522937693, 1882353782],
17 [1864922766, 1719732118, 3882010307, 1776744564],
18 [4141682960, 3310988675, 553637289, 902896340],
19 [1134851934, 2352871630, 3699409824, 2648159817],
20 [1240956131, 3107113773, 1283198141, 1924506131],
21 [2669565031, 579818610, 3042504477, 2774880435],
22 [2766103236, 2883057919, 4029656435, 862374500],
23 ]
24 outputs = [
25 [3914649087, 576849849, 3593928901, 2229911004],
26 [2240804226, 3691353228, 1365957195, 2654016646],
27 [3562296087, 3191708229, 1147942216, 3726991905],
28 [1403443605, 3591372999, 1291086759, 441919183],
29 [1086200464, 2191331643, 560336446, 3658716651],
30 [3249937430, 2346751812, 847844327, 2996632307],
31 [2584285912, 4034195531, 3523502488, 169742686],
32 [959045797, 3875435559, 1886309314, 359682705],
33 [3978441347, 432478529, 3223635119, 138903045],
34 [296367413, 4262059219, 13109864, 3283683422],
35 ]
36 outputs64 = [
37 [2477551240072187391, 9577394838764454085],
38 [15854241394484835714, 11398914698975566411],
39 [13708282465491374871, 16007308345579681096],
40 [15424829579845884309, 1898028439751125927],
41 [9411697742461147792, 15714068361935982142],
42 [10079222287618677782, 12870437757549876199],
43 [17326737873898640088, 729039288628699544],
44 [16644868984619524261, 1544825456798124994],
45 [1857481142255628931, 596584038813451439],
46 [18305404959516669237, 14103312907920476776],
47 ]
48 for seed, expected, expected64 in zip(inputs, outputs, outputs64):
49 expected = np.array(expected, dtype=np.uint32)
50 ss = SeedSequence(seed)
51 state = ss.generate_state(len(expected))
52 assert_array_equal(state, expected)
53 state64 = ss.generate_state(len(expected64), dtype=np.uint64)
54 assert_array_equal(state64, expected64)
55
56
57def test_zero_padding():

Callers

nothing calls this directly

Calls 2

assert_array_equalFunction · 0.90
generate_stateMethod · 0.80

Tested by

no test coverage detected