Test failure of 1.4.2 on 32bit platforms

3 views
Skip to first unread message

Antonio Valentino

unread,
Feb 14, 2012, 4:18:07 PM2/14/12
to Numexpr Mailing List
Hi all,
we are trying to upgrade the debian package for numexpr 1.4.2 (see [1])
but we have some test failure on 32 bit platforms (see below).

The error is generated by the following code:

x = zeros(1e5)+.01 # checks issue #41
assert_equal(evaluate("sum(x+2,axis=0)"), sum(x+2,axis=0))

and there is a comment that points to #41.
I'm wondering if the problem is actually imputable to numexpr or, maybe,
something related to numpy.

Do you have some hint?

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=Bug%23657733

set -e -x;\
for py in 2.6 2.7; do \
cd /tmp/buildd/numexpr-1.4.2/build/lib.*-$py;\
env PYTHONPATH=. python$py numexpr/tests/test_numexpr.py;\
cd /tmp/buildd/numexpr-1.4.2/build/lib.*-$py-pydebug;\
env PYTHONPATH=. python$py-dbg numexpr/tests/test_numexpr.py;\
done
+ cd /tmp/buildd/numexpr-1.4.2/build/lib.linux-i686-2.6
+ env PYTHONPATH=. python2.6 numexpr/tests/test_numexpr.py
...F......F..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
.
.
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
.
.
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
.
.
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
.
.
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
.
.
....................................................................................................................................................-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Numexpr version: 1.4.2
NumPy version: 1.5.1
Python version: 2.6.7 (r267:88850, Aug 3 2011, 15:19:01)
[GCC 4.6.1]
Platform: linux2-i686
AMD/Intel CPU? True
VML available? False
Detected cores: 1
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
..
======================================================================
FAIL: test_reductions (__main__.test_numexpr1)
----------------------------------------------------------------------
Traceback (most recent call last):
File "numexpr/tests/test_numexpr.py", line 76, in test_reductions
assert_equal(evaluate("sum(x+2,axis=0)"), sum(x+2,axis=0))
File "/usr/lib/pymodules/python2.6/numpy/testing/utils.py", line 256,
in assert_equal
return assert_array_equal(actual, desired, err_msg, verbose)
File "/usr/lib/pymodules/python2.6/numpy/testing/utils.py", line 686,
in assert_array_equal
verbose=verbose, header='Arrays are not equal')
File "/usr/lib/pymodules/python2.6/numpy/testing/utils.py", line 618,
in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not equal

(mismatch 100.0%)
x: array(201000.00000017491)
y: array(201000.00000000009)

======================================================================
FAIL: test_reductions (__main__.test_numexpr2)
----------------------------------------------------------------------
Traceback (most recent call last):
File "numexpr/tests/test_numexpr.py", line 76, in test_reductions
assert_equal(evaluate("sum(x+2,axis=0)"), sum(x+2,axis=0))
File "/usr/lib/pymodules/python2.6/numpy/testing/utils.py", line 256,
in assert_equal
return assert_array_equal(actual, desired, err_msg, verbose)
File "/usr/lib/pymodules/python2.6/numpy/testing/utils.py", line 686,
in assert_array_equal
verbose=verbose, header='Arrays are not equal')
File "/usr/lib/pymodules/python2.6/numpy/testing/utils.py", line 618,
in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not equal

(mismatch 100.0%)
x: array(201000.00000017491)
y: array(201000.00000000009)

----------------------------------------------------------------------
Ran 5145 tests in 16.368s

FAILED (failures=2)


--
Antonio Valentino

Francesc Alted

unread,
Feb 15, 2012, 11:20:54 AM2/15/12
to num...@googlegroups.com
On Feb 14, 2012, at 10:18 PM, Antonio Valentino wrote:
> Hi all,
> we are trying to upgrade the debian package for numexpr 1.4.2 (see [1])
> but we have some test failure on 32 bit platforms (see below).
>
> The error is generated by the following code:
>
> x = zeros(1e5)+.01 # checks issue #41
> assert_equal(evaluate("sum(x+2,axis=0)"), sum(x+2,axis=0))
>
> and there is a comment that points to #41.
> I'm wondering if the problem is actually imputable to numexpr or, maybe,
> something related to bumpy.

No, this is probably not related with #41, but a problem with the test itself. `assert_equal` should be replaced by `assert_almost_equal`. Please file a ticket so that can be fixed. Hmm, I suppose you would like a 1.4.3 release, right? Or you would not mind if this is fixed on 2.0.x series?

-- Francesc Alted


Antonio Valentino

unread,
Feb 15, 2012, 3:40:37 PM2/15/12
to num...@googlegroups.com
Hi Francesc,

Thank you very much Francesc.
I have just opened issue72

http://code.google.com/p/numexpr/issues/detail?id=72


Regarding numexpr 1.4.3, I suppose I can patch the testing code in the
debian package for this specific issue, so 1.4.3 is not strictly
necessary for me, thanks.

ciao

--
Antonio Valentino

Francesc Alted

unread,
Feb 16, 2012, 10:43:29 AM2/16/12
to num...@googlegroups.com
On Feb 15, 2012, at 9:40 PM, Antonio Valentino wrote:

> Hi Francesc,
>
> Il 15/02/2012 17:20, Francesc Alted ha scritto:
>> On Feb 14, 2012, at 10:18 PM, Antonio Valentino wrote:
>>> Hi all,
>>> we are trying to upgrade the debian package for numexpr 1.4.2 (see [1])
>>> but we have some test failure on 32 bit platforms (see below).
>>>
>>> The error is generated by the following code:
>>>
>>> x = zeros(1e5)+.01 # checks issue #41
>>> assert_equal(evaluate("sum(x+2,axis=0)"), sum(x+2,axis=0))
>>>
>>> and there is a comment that points to #41.
>>> I'm wondering if the problem is actually imputable to numexpr or, maybe,
>>> something related to bumpy.
>>
>> No, this is probably not related with #41, but a problem with the test itself. `assert_equal` should be replaced by `assert_almost_equal`. Please file a ticket so that can be fixed. Hmm, I suppose you would like a 1.4.3 release, right? Or you would not mind if this is fixed on 2.0.x series?
>>
>> -- Francesc Alted
>
> Thank you very much Francesc.
> I have just opened issue72
>
> http://code.google.com/p/numexpr/issues/detail?id=72

Thanks!

> Regarding numexpr 1.4.3, I suppose I can patch the testing code in the
> debian package for this specific issue, so 1.4.3 is not strictly
> necessary for me, thanks.

Sure. I'm in a hurry now, but could you please to proceed patching directly in the debian package, and tell me if the `assert_equal` -> `assert_almost_equal` translation works for 32-bit? This way, I can have a confirmation that this actually works on 32-bit and you can proceed with debian packetization.

Thanks,

-- Francesc Alted


Antonio Valentino

unread,
Feb 16, 2012, 5:08:48 PM2/16/12
to num...@googlegroups.com
Hi Francesc,

Unfortunately it seems not to work with the default value of decimal=7

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=657733


It is quite strange,
The code that generates the error is the following:

x = zeros(1e5)+.01 # checks issue #41
assert_equal(evaluate("sum(x+2,axis=0)"), sum(x+2,axis=0))

and the error message is:

(mismatch 100.0%)
x: array(201000.00000017491)
y: array(201000.00000000009)


I run that code in my IPython shell (on a 64bit platform) I get:

In [1]: import numpy as np

In [2]: import numexpr as nx

In [3]: x = np.zeros(1e5)+.01

In [4]: np.sum(x+2,axis=0)
Out[4]: 201000.00000017491

In [5]: nx.evaluate('sum(x+2,axis=0)')
Out[5]: array(201000.0000001749)

In [6]: xx = np.zeros(1e5, np.lon)+.01

In [6]: xx = np.zeros(1e5, np.longdouble)+.01

In [7]: np.sum(xx+2,axis=0)
Out[7]: 201000.00000000013557

So it seems to me that numexpr uses long double (80 bit precision) for
the computation on 32 bit platforms but it uses double (64 bit) on 64
bit platforms.

Do I miss something?

best regards

--
Antonio Valentino

Francesc Alted

unread,
Feb 17, 2012, 4:13:17 AM2/17/12
to num...@googlegroups.com

Ups, use assert_approx_equal instead:

In [18]: np.testing.assert_almost_equal(np.array(201000.00000017491), np.array(201000.00000000009))
AssertionError:
Arrays are not almost equal to 7 decimals

(mismatch 100.0%)
x: array(201000.0000001749)
y: array(201000.0000000001)

In [19]: np.testing.assert_approx_equal(np.array(201000.00000017491), np.array(201000.00000000009))

In [20]:

See docstrings to see why assert_almost_equal and assert_almost_equal behave differently.

Also, I have no idea on why NumPy computations are so exact on 32-bit platforms. I guess this is floating point black magic going on, Mark?

-- Francesc Alted


Mark Wiebe

unread,
Feb 17, 2012, 4:19:21 AM2/17/12
to num...@googlegroups.com
This would be specific to 32-bit x86, where a particular quirk of the x87 coprocessor design has meant that better accuracy and speed often coincide. The x87 floating point registers default to 80-bit precision, and if intermediate results are not copied back into memory, higher precision results. In 64-bit x86, SSE2 is used, which does not have this higher precisions.

Cheers,
Mark
 

-- Francesc Alted






--
You received this message because you are subscribed to the Google Groups "numexpr" group.
To post to this group, send email to num...@googlegroups.com.
To unsubscribe from this group, send email to numexpr+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/numexpr?hl=en.


Reply all
Reply to author
Forward
0 new messages