title: Creating numpy.float64 using eval()
body: <p>I've looked around, and did not find any information to create numpy.float64 using the built-in <code>eval</code> function.</p>
  
  <p>What I'd like is going from something like:</p>
  
  <pre><code>In [1]: x = eval("1.0")
  In [2]: type(x)
  Out[2]: &lt;type 'float'&gt;
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>In [1]: x = eval("1.0")
  In [2]: type(x)
  Out[2]: &lt;type 'numpy.float64'&gt;
  </code></pre>
  
  <p>The real problem is a bit worse than just the simple example above because the argument passed to <code>eval</code> is most often a dictionary with many keys and values. So it would not be possible to use something like: <code>numpy.float64("1.0")</code>.</p>
  
  <p>To give you concrete real data I'm working with, here is how a string could look like (it is read from a file):</p>
  
  <pre><code>data_str = '{"var_x": {"value": 1.23, "error": 0.25, "unit": "unit name"},
              "var_y": {"value": 1e+4, "error": 1.3e1, "log": False},
              "var_z": ["a", {"x":1, "y":2}, (1, 2, 3), None]'
  data = eval(data_str)
  </code></pre>
  
  <p>And then, I'd like <code>type(data["var_x"]["value"])</code> returns <code>&lt;type 'numpy.float64'&gt;</code></p>
  
  <p>Do you guys have any suggestions. Did I miss an obvious method?</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>The precision of numbers I will deal with in <code>data_str</code> will not be much more than 15-16 digits.
  So converting string to <code>float</code> or <code>numpy.float64</code> does not matter a lot for that purpose only. However these values will be passed to some complex functions, multiplied, divided... therefore to avoid any error propagation, I have to work with <code>numpy.float64</code>.
  One workaround could be to convert (after <code>eval</code>) any <code>float</code> to <code>numpy.float64</code>, but it would be nice to have a direct interpretation using <code>eval</code>.</p>
  
  <p><strong>EDIT #2</strong></p>
  
  <p>I'm wondering why this does not work:</p>
  
  <pre><code>In [1]: import numpy as np
  In [2]: x = eval("1.4", {"__builtins__":None, "np":np}, {"float":np.float64})
  In [3]: type(x)
  Out[3]: &lt;type 'float'&gt;
  </code></pre>
  
  <p>I thought by defining "__builtins__" to <code>None</code> within eval globals would avoid it to load default definition for <code>float</code>, which I redefine within the locals... It seems it is <em>impossible</em> to take out (or replace for this matter) builtin types from <code>eval</code> namespace (like <code>float</code>, <code>int</code>...). Any light on this is welcome :)</p>