<br><br><div class="gmail_quote">On Mon, Apr 11, 2011 at 12:54 PM, Skipper Seabold <span dir="ltr"><<a href="mailto:jsseabold@gmail.com">jsseabold@gmail.com</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;">
All,<br>
<br>
We noticed some failing tests for statsmodels between numpy 1.5.1 and<br>
numpy >= 1.6.0. These are the versions where I noticed the change. It<br>
seems that when you divide a float array and multiply by a boolean<br>
array the answers are different (unless the others are also off by<br>
some floating point). Can anyone replicate the following using this<br>
script or point out what I'm missing?<br>
<br>
import numpy as np<br>
print np.__version__<br>
np.random.seed(12345)<br>
<br>
test = np.random.randint(0,2,size=10).astype(bool)<br>
t = 1.345<br>
arr = np.random.random(size=10)<br>
<br>
arr # okay<br>
t/arr # okay<br>
(1-test)*arr # okay<br>
(1-test)*t/arr # huh?<br>
<br>
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)<br>
[GCC 4.4.3] on linux2<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
>>> import numpy as np<br>
>>> print np.__version__<br>
2.0.0.dev-fe3852f<br>
>>> np.random.seed(12345)<br>
>>><br>
>>> test = np.random.randint(0,2,size=10).astype(bool)<br>
>>> t = 1.345<br>
>>> arr = np.random.random(size=10)<br>
>>><br>
>>> arr # okay<br>
array([ 0.5955447 ,  0.96451452,  0.6531771 ,  0.74890664,  0.65356987,<br>
        0.74771481,  0.96130674,  0.0083883 ,  0.10644438,  0.29870371])<br>
>>> t/arr # okay<br>
array([   2.25843668,    1.39448393,    2.05916589,    1.7959515 ,<br>
          2.0579284 ,    1.79881418,    1.39913718,  160.342421  ,<br>
         12.63570742,    4.50278968])<br>
>>> (1-test)*arr # okay<br>
array([ 0.5955447 ,  0.        ,  0.        ,  0.        ,  0.65356987,<br>
        0.        ,  0.96130674,  0.0083883 ,  0.        ,  0.29870371])<br>
>>> (1-test)*t/arr # huh?<br>
array([   2.25797754,    0.        ,    0.        ,    0.        ,<br>
          2.05751003,    0.        ,    1.39885274,  160.3098235 ,<br>
          0.        ,    4.50187427])<br>
<br></blockquote><div><br>Looks like it is going through float16:<br><br>In [2]: float16(1.345)/0.5955447<br>Out[2]: 2.25797754979601<br><br>The scalar 1.345 should be converted to double and that isn't happening.<br>
<br><snip><br><br>Chuck<br></div><br></div>