Looking at some of the source code from the sklearn library:
part of the code, removing the comments:
def check_random_state(seed):
if seed is None or seed is np.random:
return np.random.mtrand._rand
if isinstance(seed, (numbers.Integral, np.integer)):
return np.random.RandomState(seed)
if isinstance(seed, np.random.RandomState):
return seed
raise ValueError('%r cannot be used to seed a numpy.random.RandomState' ' instace' % seed)
def resample(*arrays, **options):
random_state = check_random_state(options.pop('random_state', None))
replace = options.pop('replace', True)
# lots more code below ...
In particular: replace = options.pop('replace', True)
and random_state = check_random_state(options.pop('random_state', None))
how is the options.pop('object_that_is_being_created', some_value)
used? What is it's purpose? What does it do?
I know that options
will be a dictionary and that arrays
will be a tuple, but im not sure what the code actually, since it seems it just returns the second argument ?