https://github.com/tensorly/tensorly
Revision 0967e0cdd01304c234121ad89babb2ffccd2f4d2 authored by JeanKossaifi on 24 October 2016, 11:10:54 UTC, committed by JeanKossaifi on 24 October 2016, 11:10:54 UTC
1 parent 33ad3be
Tip revision: 0967e0cdd01304c234121ad89babb2ffccd2f4d2 authored by JeanKossaifi on 24 October 2016, 11:10:54 UTC
Added doc
Added doc
Tip revision: 0967e0c
base.py
import numpy as np
def check_random_state(seed):
"""Returns a valid RandomState
Parameters
----------
seed : None or instance of int or np.random.RandomState(), default is None
Returns
-------
Valid instance np.random.RandomState
Notes
-----
Inspired by the scikit-learn eponymous function
"""
if seed is None or isinstance(seed, int):
return np.random.RandomState(seed)
elif isinstance(seed, np.random.RandomState):
return seed
raise ValueError('Seed should be None, int or np.random.RandomState')
Computing file changes ...