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

Function test_zero_padding

numpy/random/tests/test_seed_sequence.py:57–80  ·  view source on GitHub ↗

Ensure that the implicit zero-padding does not cause problems.

()

Source from the content-addressed store, hash-verified

55
56
57def test_zero_padding():
58 """ Ensure that the implicit zero-padding does not cause problems.
59 """
60 # Ensure that large integers are inserted in little-endian fashion to avoid
61 # trailing 0s.
62 ss0 = SeedSequence(42)
63 ss1 = SeedSequence(42 << 32)
64 assert_array_compare(
65 np.not_equal,
66 ss0.generate_state(4),
67 ss1.generate_state(4))
68
69 # Ensure backwards compatibility with the original 0.17 release for small
70 # integers and no spawn key.
71 expected42 = np.array([3444837047, 2669555309, 2046530742, 3581440988],
72 dtype=np.uint32)
73 assert_array_equal(SeedSequence(42).generate_state(4), expected42)
74
75 # Regression test for gh-16539 to ensure that the implicit 0s don't
76 # conflict with spawn keys.
77 assert_array_compare(
78 np.not_equal,
79 SeedSequence(42, spawn_key=(0,)).generate_state(4),
80 expected42)

Callers

nothing calls this directly

Calls 3

assert_array_compareFunction · 0.90
assert_array_equalFunction · 0.90
generate_stateMethod · 0.80

Tested by

no test coverage detected