[Numpy-tickets] [NumPy] #959: atanh(+1) gives nan instead of inf on Windows

NumPy numpy-tickets@scipy....
Wed Nov 26 14:22:00 CST 2008


#959: atanh(+1) gives nan instead of inf on Windows
------------------------+---------------------------------------------------
 Reporter:  faltet      |        Owner:  somebody
     Type:  defect      |       Status:  new     
 Priority:  normal      |    Milestone:  1.3.0   
Component:  numpy.core  |      Version:  devel   
 Severity:  normal      |   Resolution:          
 Keywords:              |  
------------------------+---------------------------------------------------
Comment (by faltet):

 Replying to [comment:2 charris]:
 > The function didn't change but the configuration changes for detecting
 functions probably caused the numpy version to be used.

 You are right.  The current definition based on log1p dates from numpy
 1.0.3 at least.  So, I don't understand why this problem has not show up
 before :-/

 > What happens if you add
 >
 > #define HAVE_ATANH
 >
 > before the function?

 I've tested this before, and I remember MSVC 9 giving a link error (MSVC 9
 doesn't implement a atanh, I'm afraid).

 > In any case we need to track down the problem. The numpy version is more
 accurate for small values of x than the Mathworks version, but I suspect
 log1p might be broken for inf values. What does log1p(inf) do?

 Here you have:

 {{{
 C:\Users\francesc>python
 Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)]
 on win
 32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy
 >>> numpy.__version__
 '1.3.0.dev6109'
 >>> numpy.log1p(numpy.inf)
 nan
 >>> numpy.log(numpy.inf)
 inf
 >>> numpy.log(numpy.inf) * numpy.inf
 inf
 >>> numpy.log(numpy.inf) * numpy.inf / numpy.inf
 nan
 >>> numpy.log(1 + numpy.inf) * numpy.inf / (1 + numpy.inf -1)
 nan
 >>> numpy.inf / numpy.inf
 nan
 >>>
 }}}

 while using NumPy 1.2.1:

 {{{
 C:\Users\francesc>python
 Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
 (Intel)] on
 win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy
 >>> numpy.__version__
 '1.2.1'
 >>> numpy.log1p(numpy.inf)
 1.#INF
 >>> numpy.log(numpy.inf)
 1.#INF
 >>> numpy.log(numpy.inf) *numpy.inf
 1.#INF
 >>> numpy.log(numpy.inf) * numpy.inf / numpy.inf
 -1.#IND
 >>> numpy.log(1 + numpy.inf) * numpy.inf / (1 + numpy.inf -1)
 -1.#IND
 >>> numpy.inf / numpy.inf
 -1.#IND
 >>>
 }}}

 So, perhaps the problem is the different behavior on the outcome of
 dividing infinities.  I'm using the official numpy 1.2.1 and my own MSVC9
 compiled 1.3.  Also, it is worth noting that I'm using Python 2.5 for
 1.2.1 and Python 2.6 for 1.3.  So, we have several possibilities: the
 python interpreters are behaving differently, or it is a problem that
 depends on the MSVC compiler.  Provided that the problem is windows-
 specific (i.e. python interpreter behaves correctly in Linux), I tend to
 believe that there is a problem on the MSVC9.

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/959#comment:3>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list