Runtime warning on startup in numpy

I am getting this warning on startup:

/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/core/getlimits.py:82: 
RuntimeWarning: invalid value encountered in power
  self.resolution = float_to_float(float_conv(10) ** (-self.precision))

Probably related to https://github.com/Slicer/Slicer/pull/746?

Most likely.

By any chance, do you happen to have a complete stack trace ?

That message is all I get on the console. It is a warning, not error, so there is no stack trace.

Here it is in context:

Number of registered modules: 146
/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/core/getlimits.py:82: RuntimeWarning: invalid value encountered in power
  self.resolution = float_to_float(float_conv(10) ** (-self.precision))
Number of instantiated modules: 146

Is there a file&line number in the application log?

Yes, I included it:

/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/core/getlimits.py:82

Is there a call stack to see where the problem originates from? If not, then you could add raise Exception() before the referenced line in getlimits.py to raise an exception and get a call stack.

After adding raise Exception(), here is the stack trace. The warning is triggered on import numpy

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Applications/Slicer.app/Contents/lib/Slicer-4.7/qt-scripted-modules/DICOMScalarVolumePlugin.py", line 1, in <module>
    import numpy
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/core/__init__.py", line 51, in <module>
    from . import getlimits
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/core/getlimits.py", line 126, in <module>
    tiny=_f16(2 ** -14))
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/numpy-1.13.1-py2.7-macosx-10.6-x86_64.egg/numpy/core/getlimits.py", line 82, in __init__
    raise Exception()
Exception

Thank you. There is nothing particularly suspicious in this call stack. Maybe instead of throwing an exception, you could print the call stack and let the execution continue:

import traceback
traceback.print_stack()

This way we could see which call stack corresponds to the warning message (there may be several calls without warnings but after one of them the warning message will be printed as well).

We could also print some variables, such as self.eps and self.precision.

Do you have this warning by simply installing the latest nightly version of Slicer, without installing any extensions? There is no such warning on Windows.

Andras, I get this warning with the latest nightly on mac.

@msmolens @jcfr if you can’t reproduce this issue on mac with a nightly after https://github.com/Slicer/Slicer/pull/746 let me know, and I will investigate later as suggested by @lassoan.

FWIW I don’t get this error on my mac local build after upgrading to numpy 1.13.1. (Note: to test new numpy you need to delete it from site-package before rebuilding).

@pieper I get this warning while launching a nightly binary.

@fedorov What is you version of macOS ?

I have the same on macOS Sierra 10.12.5

I also had the warning on Sierra 10.12.5

I have the same issue on El captian 10.11.4

I just noticed that the same warning shows up in the extension builds, but it is treated as an error:

http://slicer.cdash.org/viewBuildError.php?buildid=1079946

I logged an issue about this https://issues.slicer.org/view.php?id=4419

Hi,

We will be addressing these shortly.

Thanks
Jc

1 Like

This should be addressed by the following PR.

If there are no objections, I will integrate later tonight.

Note: Developer may have to delete NUMPY-* directories before re-configuring.

2 Likes

Fixes integrated in r26337 and r26338

Note that the fix consist in temporarily disabling the warnings.

1 Like