Description
A simple import pandas
apparently does a np.seterr(all='ignore')
: https://github.com/pydata/pandas/blob/23eb483d17ce41c0fe41b0bfa72c90df82151598/pandas/compat/numpy/__init__.py#L8-L9
This is a problem when using Pandas as a library, particularly during testing: a test (completely unrelated to Pandas) that should have produced warnings can fail to do so just because some earlier test happened to import a library that imported a library that imported something from Pandas (for example). Or a test runner that's done a np.seterr(all='raise')
specifically to catch potential issues can end up catching nothing, because some Pandas import part-way through the test run turned the error handling off again.
I'm working around this right now by wrapping every pandas import in with np.errstate():
. For example:
with np.errstate():
from pandas import DataFrame
But that's (a) ugly, and (b) awkward if the pandas import is in a third-party library out of your control.
Please consider removing this feature!
Code Sample, a copy-pastable example if possible
Enthought Canopy Python 2.7.11 | 64-bit | (default, Mar 18 2016, 14:49:17)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy, pandas
>>> 1.0 / numpy.arange(10)
array([ inf, 1. , 0.5 , 0.33333333, 0.25 ,
0.2 , 0.16666667, 0.14285714, 0.125 , 0.11111111])
Expected Output
I expected to see a RuntimeWarning
from the division by zero above, as in:
Enthought Canopy Python 2.7.11 | 64-bit | (default, Mar 18 2016, 14:49:17)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> 1.0 / numpy.arange(10)
__main__:1: RuntimeWarning: divide by zero encountered in divide
array([ inf, 1. , 0.5 , 0.33333333, 0.25 ,
0.2 , 0.16666667, 0.14285714, 0.125 , 0.11111111])
output of pd.show_versions()
>>> pandas.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Darwin
OS-release: 13.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
pandas: 0.18.0
nose: 1.3.7
pip: 8.1.1
setuptools: 20.6.7
Cython: None
numpy: 1.10.4
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: 4.1.2
sphinx: None
patsy: None
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0