Skip to content

TST/CLN: some RunTimeWarnings #14057

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
6 tasks
jreback opened this issue Aug 21, 2016 · 8 comments
Closed
6 tasks

TST/CLN: some RunTimeWarnings #14057

jreback opened this issue Aug 21, 2016 · 8 comments
Labels
Clean Closing Candidate May be closeable, needs more eyeballs good first issue Testing pandas testing functions or related to the test suite

Comments

@jreback
Copy link
Contributor

jreback commented Aug 21, 2016

after #13145 some RunTimeWarnings remain in the codebase. We should look at these and silence (using np.errstate), or fix if we are testing something odd. (running the full test suite will show these; I have extracted them, some are showing a level too low in the stack).

  • pandas/pandas/tseries/index.py:526: RuntimeWarning: overflow encountered in long_scalars return lambda x: Timestamp(x, freq=self.offset, tz=self.tz)
  • pandas/pandas/tseries/tests/test_tslib.py:453: RuntimeWarning: overflow encountered in long_scalar self.assertIs(ts.tz_localize(tz, errors='coerce'),
  • pandas/pandas/core/internals.py:2341: RuntimeWarning: overflow encountered in long_scalar f = lambda x: lib.Timestamp(x, tz=self.values.tz)
  • pandas/pandas/core/internals.py:4753: ComplexWarning: Casting complex values to real discards the imaginary part nn_at = nn.astype(v.dtype)
  • pandas/pandas/tests/test_algos.py:735: RuntimeWarning: overflow encountered in long_scalars np.array([pd.Timestamp(d, tz='US/Eastern') for d in dt]),
  • pandas/pandas/core/ops.py:650: RuntimeWarning: invalid value encountered in double_scalars lambda x: op(x, rvalues))
@jreback jreback added Testing pandas testing functions or related to the test suite Difficulty Novice labels Aug 21, 2016
@jreback jreback added this to the Next Major Release milestone Aug 21, 2016
@jreback
Copy link
Contributor Author

jreback commented Aug 21, 2016

cc @rkern

@Liam3851
Copy link
Contributor

Also since 0.19.0 but still in current master: pandas/pandas/core/generic.py:5126: RuntimeWarning: invalid value encountered in absolute return np.abs(self)


In [1]: import numpy as np; import pandas as pd                                                       

In [2]: pd.__version__                                                                                
Out[2]: '0.19.0+52.g096d886' 

In [3]: pd.Series([1, -2.0, np.NaN]).abs()                                                            
C:\AnacondaBleeding\lib\site-packages\pandas\core\generic.py:5126: RuntimeWarning: invalid value encountered in absolute                                                                                    
  return np.abs(self)                                                                                 
Out[3]:                                                                                               
0    1.0                                                                                              
1    2.0                                                                                              
2    NaN                                                                                              
dtype: float64                                                                                        

@jreback
Copy link
Contributor Author

jreback commented Oct 29, 2016

@Liam3851 you would have to show more information, e.g. pd.show_versions(). This has worked for quite a number of versions already as is not related this issue. more likely a numpy / platform version I think.

In [2]: pd.__version__
Out[2]: '0.19.0+53.g7f5a45c'

In [3]: pd.Series([1, -2.0, np.NaN]).abs()     
Out[3]: 
0    1.0
1    2.0
2    NaN
dtype: float64

In [4]: np.__version__
Out[4]: '1.11.2'

@Liam3851
Copy link
Contributor

Liam3851 commented Nov 1, 2016

Thanks Jeff. I'm still showing with numpy 1.11.2 on Windows 7. Here's pd.show_versions;

In [1]: import numpy as np; import pandas as pd                                                                        

In [2]: pd.show_versions()                                                                                             

INSTALLED VERSIONS                                                                                                     
------------------                                                                                                     
commit: 096d8866a90c8cbb44ab8243320e811fc24190bd                                                                       
python: 2.7.12.final.0                                                                                                 
python-bits: 64                                                                                                        
OS: Windows                                                                                                            
OS-release: 7                                                                                                          
machine: AMD64                                                                                                         
processor: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel                                                          
byteorder: little                                                                                                      
LC_ALL: None                                                                                                           
LANG: None                                                                                                             
LOCALE: None.None                                                                                                      

pandas: 0.19.0+52.g096d886                                                                                             
nose: 1.3.7                                                                                                            
pip: 8.1.2                                                                                                             
setuptools: 27.2.0                                                                                                     
Cython: 0.24.1                                                                                                         
numpy: 1.11.2                                                                                                          
scipy: 0.18.1                                                                                                          
statsmodels: None                                                                                                      
xarray: None                                                                                                           
IPython: 5.1.0                                                                                                         
sphinx: 1.4.8                                                                                                          
patsy: None                                                                                                            
dateutil: 2.5.3                                                                                                        
pytz: 2016.7                                                                                                           
blosc: None                                                                                                            
bottleneck: None                                                                                                       
tables: 3.2.2                                                                                                          
numexpr: 2.6.1                                                                                                         
matplotlib: 1.5.3                                                                                                      
openpyxl: 2.4.0                                                                                                        
xlrd: 1.0.0                                                                                                            
xlwt: 1.1.2                                                                                                            
xlsxwriter: None                                                                                                       
lxml: 3.6.4                                                                                                            
bs4: None                                                                                                              
html5lib: None                                                                                                         
httplib2: None                                                                                                         
apiclient: None                                                                                                        
sqlalchemy: 1.0.13                                                                                                     
pymysql: None                                                                                                          
psycopg2: None                                                                                                         
jinja2: 2.8                                                                                                            
boto: None                                                                                                             
pandas_datareader: None                                                                                                

In [3]: pd.Series([1, -2.0, np.NaN]).abs()                                                                             
pandas\core\generic.py:5126: RuntimeWarning: invalid value encountered in absolute                                     
  return np.abs(self)                                                                                                  
Out[3]:                                                                                                                
0    1.0                                                                                                               
1    2.0                                                                                                               
2    NaN                                                                                                               
dtype: float64                                                                                                         

@jreback
Copy link
Contributor Author

jreback commented Nov 1, 2016

can you step thru and see exactly where this is coming from? I cannot repro

@Liam3851
Copy link
Contributor

Liam3851 commented Nov 1, 2016

Odd. Do you see the error with raw numpy outside pandas?

In [1]: import numpy as np                                                                                             

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

NDFrame.abs is just calling np.abs(self). I can kill the warning by adding

with np.errstate(invalid='ignore'):

before the return np.abs(self) at line 5126.

@jreback
Copy link
Contributor Author

jreback commented Nov 1, 2016

actually I can repro only on 2.7 on windows. I think this is a numpy bug actually (if you'd like to search / report if its not there).

λ python
Python 2.7.12 |Continuum Analytics, Inc.| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)] on win32
>>> import numpy as np
>>> np.abs(np.array([1, -2., np.nan]))
__main__:1: RuntimeWarning: invalid value encountered in absolute
array([  1.,   2.,  nan])
>>>

In any event, let's up a np.errstate in pandas around in .abs()

@mroeschke
Copy link
Member

I believe we took care of our warnings a while back so going to close this issue. Should open up separate newer issues if they still exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Closing Candidate May be closeable, needs more eyeballs good first issue Testing pandas testing functions or related to the test suite
Projects
None yet
Development

No branches or pull requests

5 participants