Skip to content

ncu.log1p(np.nan) produces a RuntimeWarning #5017

Closed

Description

@didickman

The below is produced with numpy 1.9.0rc1 on an OpenBSD/i386 system.

Python 2.7.8 (default, Aug 27 2014, 00:06:02)
[GCC 4.2.1 20070719 ] on openbsd5
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy.core.umath as ncu
>>> import numpy as np
>>> ncu.log1p(np.nan)
__main__:1: RuntimeWarning: invalid value encountered in log1p
nan
>>> np.log1p(np.nan)
nan

Activity

  1. charris commented on Aug 29, 2014

    @charris
    Member

    This presence or this warning depends on the hardware/compiler, but is not unexpected for a nan argument. Is it a problem for you?

  2. njsmith commented on Aug 29, 2014

    @njsmith
    Member

    Not at a real computer so I can't check details but:

    • why are you surprised that calling log1p on a nan raises a warning?
    • I think ncu.log1p and np.log1p are the same object, and the only reason
      that you get a warning for one and not the other is that by default
      warnings are only issued once.

    The below is produced with numpy 1.9.0rc1 on an OpenBSD/i386 system.

    Python 2.7.8 (default, Aug 27 2014, 00:06:02)
    [GCC 4.2.1 20070719 ] on openbsd5
    Type "help", "copyright", "credits" or "license" for more information.

    import numpy.core.umath as ncu
    import numpy as np
    ncu.log1p(np.nan)
    main:1: RuntimeWarning: invalid value encountered in log1p
    nan
    np.log1p(np.nan)
    nan

    —
    Reply to this email directly or view it on GitHub
    #5017.

  3. didickman commented on Aug 29, 2014

    @didickman
    Author

    Thanks for taking a look. The reason it looked odd enough for me to report it is that this is the only code in the test suite that reports a RuntimeWarning on i386.

    (and I confirmed that switching the order of np.log1p and ncu.log1p does indeed raise a warning only one time as was suspected.)

  4. charris commented on Aug 29, 2014

    @charris
    Member

    @didickman If it raises a warning in the test suite, we should deal with it. Can you determine which test is was? Might need to run the test with the verbosity turned up.

  5. didickman commented on Aug 29, 2014

    @didickman
    Author

    From memory, I believe it's TestLog1p in ./numpy/core/tests/test_umath.py.

    If you need me to confirm, a pointer how to turn verbosity up would be great.

  6. charris commented on Aug 29, 2014

    @charris
    Member

    Outside of the repo

    charris@localhost [~]$ python -c"import numpy; numpy.test(verbose=2)"
    

    or in the git repo

    charris@localhost [numpy.git (master)]$ python runtests.py -v
    
  7. charris commented on Aug 29, 2014

    @charris
    Member

    Look in the build directory for config.h and see if HAVE_LOG1PL is defined. I'm suspecting that it is missing from the gcc library and numpy is falling back on its own version.

  8. charris commented on Aug 29, 2014

    @charris
    Member

    Or the gcc library is just old...

  9. added a commit that references this issue on Aug 29, 2014
    affeaf5
  10. charris commented on Aug 29, 2014

    @charris
    Member

    #5020 should silence the warning.

  11. didickman commented on Aug 30, 2014

    @didickman
    Author

    Confirmed. The patch does indeed silence the warning. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions