MCPcopy Create free account
hub / github.com/dask/dask / test_random_state_data

Function test_random_state_data

dask/tests/test_utils.py:247–268  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

245
246
247def test_random_state_data():
248 np = pytest.importorskip("numpy")
249 seed = 37
250 state = np.random.RandomState(seed)
251 n = 10000
252
253 # Use an integer
254 states = random_state_data(n, seed)
255 assert len(states) == n
256
257 # Use RandomState object
258 states2 = random_state_data(n, state)
259 for s1, s2 in zip(states, states2):
260 assert s1.shape == (624,)
261 assert (s1 == s2).all()
262
263 # Consistent ordering
264 states = random_state_data(10, 1234)
265 states2 = random_state_data(20, 1234)[:10]
266
267 for s1, s2 in zip(states, states2):
268 assert (s1 == s2).all()
269
270
271def test_memory_repr():

Callers

nothing calls this directly

Calls 3

random_state_dataFunction · 0.90
RandomStateMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected