<br><br><div class="gmail_quote">On Tue, Mar 15, 2011 at 10:20 AM, Mark Sienkiewicz <span dir="ltr"><<a href="mailto:sienkiew@stsci.edu">sienkiew@stsci.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
The usual expectation is that (when possible) repr() returns a value<br>
that you can eval() to get the original data back.  But,<br>
<br>
 >>> from numpy import *<br>
 >>> a = array( [  16.50698631688883822 ] )<br>
 >>> b = eval(repr(a))<br>
 >>> a-b<br>
array([ -3.11116111e-09])<br>
 >>> import numpy.testing<br>
 >>> numpy.testing.assert_array_almost_equal(a,b,decimal=15)<br>
Traceback (most recent call last):<br>
  File "<stdin>", line 1, in <module><br>
  File "/usr/stsci/pyssgdev/2.7/numpy/testing/utils.py", line 775, in<br>
assert_array_almost_equal<br>
    header=('Arrays are not almost equal to %d decimals' % decimal))<br>
  File "/usr/stsci/pyssgdev/2.7/numpy/testing/utils.py", line 618, in<br>
assert_array_compare<br>
    raise AssertionError(msg)<br>
AssertionError:<br>
Arrays are not almost equal to 15 decimals<br>
<br>
(mismatch 100.0%)<br>
 x: array([ 16.50698632])<br>
 y: array([ 16.50698632])<br>
 >>><br>
<br>
I noticed this because a bunch of tests failed exactly this way.  Of<br>
course, the problem is that assert_array_almost_equal does not print<br>
with the precision that it compared, which in turn happens because it<br>
just uses repr() to convert the array.<br>
<br>
I would expect that repr would print the values at least to the<br>
resolution that they are stored, so I think this is a bug.<br>
<br>
This happens with the current trunk of numpy in python 2.7 on Red Hat<br>
Enterprise linux in 32 and 64 bits, and on Macintosh Leopard in 32<br>
bits.  I did not try any other configuration.<br>
<br></blockquote><div><br>Yes, I think it is a bug. IIRC, it also shows up for object arrays.<br><br>Chuck <br></div><br></div>