1

I have a simple random test code in python-3, where I generate a few random numbers, and do some processing with them, something like this:

random.seed(9001)
while True:
    x = numpy.random.rand((10, 10))
    do_some_processing(x)

My problem is that when I fix the seed, ie it becomes a deterministic run, then the code works fine. But when I delete the seed line, then sometimes the code reports errors. So I need to know for what seed value were the random numbers generated which created the failures.

So, how can I know and print the seed value, so that I can replicate the failure test?

R71
  • 4,283
  • 7
  • 32
  • 60
  • 1
    Are you using the Python std. lib. `random`, or NumPy's `random`? (They're two separate systems, and the code you show is seeding Python's `random` but drawing samples from NumPy's `random` package.) – Mark Dickinson Jul 26 '18 at 16:02
  • actually, I was using python's random, but I was not aware that numpy's random was different. Thanks for pointing that out. – R71 Jul 26 '18 at 16:41

0 Answers0