C Module's '1.#INF' changes to 'inf' at Python

CELEN Erman Erman.CELEN at 3ds.com
Mon Jan 11 13:27:07 EST 2010


> Numeric.log10() will check to see if the errno was set to ERANGE. It does not 
> check if a floating point exception flag was set, which is tricky to do across 
> platforms. The newer numpy can do it because we've finally managed to implement 
> all of that platform-specific code, but the earlier Numeric does not. 
> Presumably, the msvc8 C runtime's implementation of log10() sets errno and the 
> msvc9 runtime's version does not.

It doesn't seem like C part is changed. I confirmed that the behavior of log10(0.0) in C's standard math.h library didn't change between compilers (msvc8 and msvc9 both sets the errno to 34(ERANGE)). Now I'm thinking that this setting errno problem is happening somewhere in Numeric's log10 wrappers. 

As I see, Numeric's "PyUFunc_GenericFunction" checks errno value to see if the called function has set it and if it is non-zero, it calls math_error which raises the exception. The problem is that now errno is not being set but I can't see why since I can't step into that redirected function call ("*(double *)op = ((DoubleUnaryFunc *)func)(*(double *)ip1)" where function value is "0x01c4ede0 log10").

I am wondering which functions are actually being called when I call log10(0.0). Could you (or anybody) point me where this errno is supposed to be set in Numeric or umath when I call log10(0.0) so that I can take a look at why this is not being the case.

(I also noticed that this behavior is same under standard NumPy 1.4 with standard Python 2.6 on Windows. If you call numpy.log10(0.0) you will get an "-inf" and no exceptions will be raised. Which is not the case with Python's standard math.log10(0.0) which will raise a ValueError)

Best Regards,

Ali Erman CELEN
Platform Specialists / Porting



This email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged.  If you are not one of the named recipients or have received this email in error, (i) you should not read, disclose, or copy it, (ii) please notify sender of your receipt by reply email and delete this email and all attachments, (iii) Dassault Systemes does not accept or assume any liability or responsibility for any use of or reliance on this email.For other languages, go to http://www.3ds.com/terms/email-disclaimer.



More information about the Python-list mailing list