title: convert string representation of array to numpy array in python
body: <p>I can <a href="https://stackoverflow.com/questions/1894269/convert-string-representation-of-list-to-list-in-python">convert a string representation of a list to a list</a> with <code>ast.literal_eval</code>. Is there an equivalent for a numpy array?</p>
  
  <pre><code>x = arange(4)
  xs = str(x)
  xs
  '[0 1 2 3]'
  # how do I convert xs back to an array
  </code></pre>
  
  <p>Using <code>ast.literal_eval(xs)</code> raises a <code>SyntaxError</code>. I can do the string parsing if I need to, but I thought there might be a better solution.</p>