# Runtime warning on startup in numpy

**URL:** <https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757>\
**Category:** Development\
**Created:** [July 24, 2017, 3:16pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757 "2017-07-24T15:16:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [July 24, 2017, 3:16pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/1 "2017-07-24T15:16:01Z")

</div>

I am getting this warning on startup:

```auto
/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](https://github.com/Slicer/Slicer/pull/746)?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [July 24, 2017, 3:29pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/2 "2017-07-24T15:29:41Z")

</div>

Most likely.

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

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [July 24, 2017, 3:32pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/3 "2017-07-24T15:32:12Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 24, 2017, 4:09pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/4 "2017-07-24T16:09:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [July 24, 2017, 4:20pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/5 "2017-07-24T16:20:45Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 24, 2017, 4:30pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/6 "2017-07-24T16:30:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [July 24, 2017, 4:45pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/7 "2017-07-24T16:45:09Z")

</div>

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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 24, 2017, 5:25pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/8 "2017-07-24T17:25:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [July 24, 2017, 6:13pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/9 "2017-07-24T18:13:05Z")

</div>

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](https://github.com/Slicer/Slicer/pull/746) let me know, and I will investigate later as suggested by @lassoan.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 24, 2017, 7:33pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/10 "2017-07-24T19:33:54Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [July 24, 2017, 8:01pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/11 "2017-07-24T20:01:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [July 25, 2017, 3:38am UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/12 "2017-07-25T03:38:31Z")

</div>

@fedorov What is you version of macOS ?

---

<div class="post-metadata">

**Author:** ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)\
**Post date:** [July 25, 2017, 8:19am UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/13 "2017-07-25T08:19:26Z")

</div>

I have the same on macOS Sierra 10.12.5

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [July 25, 2017, 1:28pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/14 "2017-07-25T13:28:42Z")

</div>

I also had the warning on Sierra 10.12.5

---

<div class="post-metadata">

**Author:** ![leochan2009](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/leochan2009/32/519_2.png) [@leochan2009](https://discourse.slicer.org/u/leochan2009)\
**Post date:** [August 10, 2017, 6:25pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/15 "2017-08-10T18:25:44Z")

</div>

I have the same issue on El captian 10.11.4

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [August 15, 2017, 1:41pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/16 "2017-08-15T13:41:48Z")

</div>

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](http://slicer.cdash.org/viewBuildError.php?buildid=1079946)

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [August 22, 2017, 9:15pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/17 "2017-08-22T21:15:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [August 22, 2017, 9:34pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/18 "2017-08-22T21:34:48Z")

</div>

Hi,

We will be addressing these shortly.

Thanks  
Jc

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [September 4, 2017, 9:01pm UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/19 "2017-09-04T21:01:11Z")

</div>

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.

> <https://github.com/Slicer/Slicer/issues/786>
>
> This issue was created automatically from an original Mantis Issue. Further discussion may take place here.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [September 5, 2017, 4:24am UTC](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757/20 "2017-09-05T04:24:07Z")

</div>

Fixes integrated in [r26337](http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=26337) and [r26338](http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=26338)

Note that the fix consist in temporarily disabling the warnings.

> <https://github.com/Slicer/Slicer/blob/master/SuperBuild/numpy-03-core-getlimits-ignore-warnings.patch>

[Next page](https://discourse.slicer.org/t/runtime-warning-on-startup-in-numpy/757.md?page=2)
