# [Numpy-discussion] Numexpr giving randomized results on arrays larger than 2047 elements

John Salvatier jsalvati at u.washington.edu
Mon Jan 24 13:29:41 EST 2011

```I also get the same issue with prod()

On Mon, Jan 24, 2011 at 10:23 AM, Warren Weckesser <
warren.weckesser at enthought.com> wrote:

> I see the same "randomness", but at a different array size:
>
> In [23]: numpy.__version__
> Out[23]: '1.4.0'
>
> In [24]: import numexpr
>
> In [25]: numexpr.__version__
> Out[25]: '1.4.1'
>
> In [26]: x = zeros(8192)+0.01
>
> In [27]: print evaluate('sum(x, axis=0)')
> 72.97
>
> In [28]: print evaluate('sum(x, axis=0)')
> 66.92
>
> In [29]: print evaluate('sum(x, axis=0)')
> 67.9
>
> In [30]: x = zeros(8193)+0.01
>
> In [31]: print evaluate('sum(x, axis=0)')
> 72.63
>
> In [32]: print evaluate('sum(x, axis=0)')
> 71.74
>
> In [33]: print evaluate('sum(x, axis=0)')
> 81.93
>
> In [34]: x = zeros(8191)+0.01
>
> In [35]: print evaluate('sum(x, axis=0)')
> 81.91
>
> In [36]: print evaluate('sum(x, axis=0)')
> 81.91
>
>
> Warren
>
>
>
> On Mon, Jan 24, 2011 at 12:19 PM, John Salvatier <
> jsalvati at u.washington.edu> wrote:
>
>> Forgot to mention that I am using numexpr 1.4.1 and numpy 1.5.1
>>
>>
>> On Mon, Jan 24, 2011 at 9:47 AM, John Salvatier <
>> jsalvati at u.washington.edu> wrote:
>>
>>> Hello,
>>>
>>> I have discovered a strange bug with numexpr. numexpr.evaluate gives
>>> randomized results on arrays larger than 2047 elements. The following
>>> program demonstrates this:
>>>
>>> from numpy import *
>>> from numexpr import evaluate
>>>
>>> def func(x):
>>>
>>>     return evaluate("sum(x, axis = 0)")
>>>
>>>
>>> x = zeros(2048)+.01
>>>
>>> print evaluate("sum(x, axis = 0)")
>>> print evaluate("sum(x, axis = 0)")
>>>
>>> For me this prints different results each time, for example:
>>>
>>> 11.67
>>> 14.84
>>>
>>> If we set the size to 2047 I get consistent results.
>>>
>>> 20.47
>>> 20.47
>>>
>>> Interestingly, if I do not add .01 to x, it consistently sums to 0.
>>
>>
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110124/a392de06/attachment.html>
```