title: Can I create a local numpy random seed?
body: <p>There is a function, <code>foo</code>, that uses the <code>np.random</code> functionality.
  I want to control the seed that <code>foo</code> uses, but without actually changing the function itself.
  How do I do this?</p>
  
  <p>Essentially I want something like this:</p>
  
  <pre><code>bar() # should have normal seed
  with np.random.seed(0): # Doesn't work
      foo()
  bar() # should have normal seed
  </code></pre>
  
  <hr>
  
  <p>Solutions like 
  <a href="https://stackoverflow.com/questions/37355985/how-to-use-pythons-random-number-generator-with-a-local-seed">this</a>:</p>
  
  <pre><code>rng = random.Random(42)
  number = rng.randint(10, 20)
  </code></pre>
  
  <p>doesn't work in this case, as I don't have access to the inner workings of <code>foo</code> (or am I missing something??).</p>