mercredi 20 avril 2016

Seed numpy.random.RandomState with hashlib hash

I want to seed numpy.random.RandomState instance with an hashlib generated hash to have pseudorandom source always generating same values for same input data. When I try to do that this way:

hash = sha256(some_data)
RandomState(seed=hash.digest())

I get:

ValueError: object of too small depth for desired array

I could do map(ord, hash.digest()) but I don't know if it is right solution. Should I do that or will I lose randomness?




Aucun commentaire:

Enregistrer un commentaire