You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: nan's yield warnings in sign, greater_equal, and elsewhere #8945
I believe sign should handle NaN's silently, but it yields a warning:
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 19 2016, 13:29:36) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy as np
>>> x = np.float64([-2, -1, 0, 1, 2])
>>> np.sign(x)
array([-1., -1., 0., 1., 1.])
>>> y = x.copy()
>>> y[2] = np.nan
>>> y
array([ -2., -1., nan, 1., 2.])
>>> np.sign(y)
__main__:1: RuntimeWarning: invalid value encountered in sign
array([ -1., -1., nan, 1., 1.])
>>> np.version.version
'1.12.1'
I also see similar warnings with greater_equal, less_equal, and absolute in a call to matplotlib symlog:
C:\Anaconda2\lib\site-packages\matplotlib\scale.py:290: RuntimeWarning: invalid value encountered in sign
sign = np.sign(a)
C:\Anaconda2\lib\site-packages\numpy\ma\core.py:2123: RuntimeWarning: invalid value encountered in greater_equal
condition = (xf >= v1) & (xf <= v2)
C:\Anaconda2\lib\site-packages\numpy\ma\core.py:2123: RuntimeWarning: invalid value encountered in less_equal
condition = (xf >= v1) & (xf <= v2)
C:\Anaconda2\lib\site-packages\matplotlib\scale.py:297: RuntimeWarning: invalid value encountered in absolute
ma.log(np.abs(masked) / self.linthresh) / self._log_base)
Windows 7 x64
Anaconda 4.3.1+ (custom to bring in np 1.12)
Python 2.7.13
numpy 1.12.1
This may be related to #8230, which suggests this is unique to Windows and Python 2.7, and #7440. The latter suggests it is a 32-bit problem but my environment is 64-bit. I don't think this was an issue with an earlier version of numpy, but I'm not sure of the prior version I used. It couldn't be more than a couple of years old.
Activity
Liam3851 commentedon May 3, 2018
Does not reproduce on Windows 7 under 1.14.2/Python 2.7.15. See my closure of #8230.
galentx commentedon May 5, 2018
I'm afraid it DOES reproduce under my numpy 1.14.2/Python 2.7.15:
pepicello commentedon Nov 6, 2019
I can report this also happens with Windows 64bit and numpy 1.16.4 / Python 3.7.4
mhvk commentedon Nov 17, 2019
We're seeing this too in our astropy testing - on windows only.
Chill down with some overzealous failure/warning catching.
Chill down with some overzealous failure/warning catching.
fengluoqiuwu commentedon Oct 27, 2024
The warning doesn't occur in
2.2.0.dev0+git20241024.88a6a00,Python 3.12.7with Windows64.mattip commentedon Sep 25, 2025
Seems to have been fixed somewhere between 1.16 and 2.2. Closing, please reopen if the issue reappears.