MCPcopy Create free account
hub / github.com/apache/arrow / random_seed

Function random_seed

python/pyarrow/tests/util.py:54–72  ·  view source on GitHub ↗

Set the random seed inside of a context manager. Parameters ---------- seed : int The seed to set Notes ----- This function is useful when you want to set a random seed but not affect the random state of other functions using the random module.

(seed)

Source from the content-addressed store, hash-verified

52
53@contextlib.contextmanager
54def random_seed(seed):
55 """Set the random seed inside of a context manager.
56
57 Parameters
58 ----------
59 seed : int
60 The seed to set
61
62 Notes
63 -----
64 This function is useful when you want to set a random seed but not affect
65 the random state of other functions using the random module.
66 """
67 original_state = random.getstate()
68 random.seed(seed)
69 try:
70 yield
71 finally:
72 random.setstate(original_state)
73
74
75def randdecimal(precision, scale):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected