[Numpy-discussion] floating point exception weirdness

Andrew Straw strawman at astraw.com
Tue Aug 10 23:27:00 CDT 2004


Hi All,

I've isolated numarray.ieeespecial as the cause of a strange error which 
I posted on c.l.py:
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=41198B29.7090600%40NOSPAM-DELETE-THIS.astraw.com&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.lang.python

My non-expert guess as to an explanation: some statements early in 
numarray.ieeespecial (e.g. _na.array(1.0)/_na.array(0.0)) result in a 
floating point exception being set which lies dormant until I call 
certain functions in the Intel IPP library (e.g. 
ippiAddWeighted_8u32f_C1IR), at which point the latent exception bit my 
Python program is killed while the console says "Floating point exception".

I've come to this tentative conclusion based on 3 minimal Pyrex programs:

---------------------------------------------------- Version 1:
import numarray.numarrayall as _na
plus_inf = inf = _na.array(1.0)/_na.array(0.0)

cimport avg
avg.work() # calls IPP, terminates with "Floating point exception".
---------------------------------------------------- Version 2:
import numarray.numarrayall as _na

# Define *ieee special values*
_na.Error.pushMode(all="ignore")
plus_inf = inf = _na.array(1.0)/_na.array(0.0)
_na.Error.popMode()

cimport avg
avg.work() # calls IPP, terminates with "Floating point exception".
---------------------------------------------------- Version 3:
import numarray.numarrayall as _na
cimport avg
avg.work() # calls IPP, terminates normally

In the short term, I'll try and work around this problem by not 
importing numarray.ieeespecial, but in the long term, I think we should 
try and fix this.  I'm happy to try to debug further if someone gives me 
advice on where to go from here.

Cheers!
Andrew






More information about the Numpy-discussion mailing list