Skip to content

BUG: warning on abs with nan on python 2.7, but not on 3.5 #8230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Liam3851 opened this issue Nov 1, 2016 · 2 comments
Closed

BUG: warning on abs with nan on python 2.7, but not on 3.5 #8230

Liam3851 opened this issue Nov 1, 2016 · 2 comments

Comments

@Liam3851
Copy link

Liam3851 commented Nov 1, 2016

Both of the below are on numpy 1.11.2:

On python 2.7 on Windows, taking np.abs on an array with nan generates a RuntimeWarning:

In [1]: import numpy as np                                                                                             
                                                                                                                       
In [2]: np.abs(np.array([1, -2, np.nan]))                                                                              
C:\AnacondaBleeding\Scripts\ipython-script.py:1: RuntimeWarning: invalid value encountered in absolute                 
  if __name__ == '__main__':                                                                                           
Out[2]: array([  1.,   2.,  nan])

On python 3.5, doing the same command does not generate a warning.

In [1]: import numpy as np                                                                                             
                                                                                                                       
In [2]: np.abs(np.array([1, -2, np.nan]))                                                                              
Out[2]: array([  1.,   2.,  nan])                                                                                      

I don't have access to a Linux machine but I gather the warning is limited to python 2.7 running on Windows. Presumably the warning behavior should be consistent across platforms/python versions?

xref pandas-dev/pandas#14057

@charris
Copy link
Member

charris commented Nov 2, 2016

I suspect it is compiler/library dependent. Python 3.5 on windows uses a much more recent compiler than Python 2.7.

@Liam3851
Copy link
Author

Liam3851 commented May 3, 2018

Bug no longer exists in numpy version 1.14.2 on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants