Skip to content

np.log1p(inf) returns NaN while it should return inf #4225

Closed

Description

@pbrod

I am using numpy version 1.8.0 on windows 7 and here is the result for np.log1p

In [2]: np.log1p(np.inf)
Out[2]: nan

In [3]: np.version
Out[3]: '1.8.0'

Activity

  1. WarrenWeckesser commented on Jan 23, 2014

    @WarrenWeckesser
    Member

    I get the following on Windows 7 (64 bit), using Anaconda 1.7.0, which includes numpy 1.7.1 (that's all I have installed in my Windows VM at the moment):

    >>> import numpy as np
    >>> np.__version__
    '1.7.1'
    >>> np.log1p(np.inf)
    __main__:1: RuntimeWarning: invalid value encountered in log1p
    nan
    

    np.log works as expected:

    >>> np.log(np.inf)
    inf
    

    Also, np.expm1 gives nan when it should give inf:

    >>> np.expm1(np.inf)
    __main__:1: RuntimeWarning: invalid value encountered in expm1
    nan
    >>> np.exp(np.inf)
    inf
    
  2. juliantaylor commented on Jan 23, 2014

    @juliantaylor
    Contributor

    looks like our no-C99 fallback is not C99 compliant again, it divides inf/inf = nan

    does windows really not have C99 math or are our binary builds just not correct?

  3. juliantaylor commented on Mar 2, 2014

    @juliantaylor
    Contributor

    the mingw binaries which we have on sourceforge seem ok, so its just the ms compiler builds that are broken.

    while i know ms does not care about C99 as the language, do they really not care about correct math? C++ likely uses the same library.
    Fixes for the non mingw buildsystem are appreciated.

  4. added 3 commits that reference this issue on Mar 2, 2014
    18cda3b
    f53ab41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions