Why can I call the Numpy RandomState method?

I am learning Python and I found the following code:

rgen = np.random.RandomState(self.random_state)

In this code self.random_statethere int. I looked at the documentation and found that it RandomState(int)does not exist as a method, but is only a container of methods.

So how can you call RandomState(self.random_state)?

+4
source share
1 answer

RandomStateis a class, but RandomState(whatever_arguments)simply creates a new instance of the class RandomState.

__init__ (/ __new__), . , , docstring , ,

class numpy.random.RandomState

.

RandomState , . , , , None. None, . , 1- , . , .

. RandomState, , , , . , NumPy, , . , .

:

seed: {None, int, array_like},

, . 0 2 ** 32 - 1 , ( ) None ( ). seed - None, RandomState /dev/urandom ( Windows), , .

0

Source: https://habr.com/ru/post/1691270/


All Articles