MCPcopy Create free account
hub / github.com/PythonOT/POT / check_random_state

Function check_random_state

ot/utils.py:584–603  ·  view source on GitHub ↗

r"""Turn `seed` into a np.random.RandomState instance Parameters ---------- seed : None | int | instance of RandomState If `seed` is None, return the RandomState singleton used by np.random. If `seed` is an int, return a new RandomState instance seeded with `seed`.

(seed)

Source from the content-addressed store, hash-verified

582
583
584def check_random_state(seed):
585 r"""Turn `seed` into a np.random.RandomState instance
586
587 Parameters
588 ----------
589 seed : None | int | instance of RandomState
590 If `seed` is None, return the RandomState singleton used by np.random.
591 If `seed` is an int, return a new RandomState instance seeded with `seed`.
592 If `seed` is already a RandomState instance, return it.
593 Otherwise raise ValueError.
594 """
595 if seed is None or seed is np.random:
596 return np.random.mtrand._rand
597 if isinstance(seed, (int, np.integer)):
598 return np.random.RandomState(seed)
599 if isinstance(seed, np.random.RandomState):
600 return seed
601 raise ValueError(
602 "{} cannot be used to seed a numpy.random.RandomState instance".format(seed)
603 )
604
605
606def get_coordinate_circle(x):

Calls

no outgoing calls

Tested by

no test coverage detected