mardi 26 mai 2020

How to initialize an instance attribute as a numpy array?

I am trying to initialize a 10 by 5 binary matrix of random binary values as a instance attribute. At the moment I simply initialize it as a list and convert it to a numpy array in a separate function. Is there a better way to do this?

self.pop = np.random.randint(2, size=args)
self.pop = self.pop.astype(int)

This is how I do it in the function




Aucun commentaire:

Enregistrer un commentaire