From 8bc7f60990a835851d99b746af201cc1be6d5621 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Fri, 12 Feb 2016 11:28:12 -0500 Subject: [PATCH] COMPAT: silence mpl_style warnings closes #12311 WARN: remove warnings from categorical tests with .str.extract --- pandas/core/config.py | 6 +++++- pandas/core/config_init.py | 2 +- pandas/tests/test_categorical.py | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pandas/core/config.py b/pandas/core/config.py index b6f00034429b2..7b1e5b29f1cbb 100644 --- a/pandas/core/config.py +++ b/pandas/core/config.py @@ -127,7 +127,11 @@ def _set_option(*args, **kwargs): root[k] = v if o.cb: - o.cb(key) + if silent: + with warnings.catch_warnings(record=True): + o.cb(key) + else: + o.cb(key) def _describe_option(pat='', _print_desc=True): diff --git a/pandas/core/config_init.py b/pandas/core/config_init.py index cf8a06465a7a4..f9b91db608093 100644 --- a/pandas/core/config_init.py +++ b/pandas/core/config_init.py @@ -253,7 +253,7 @@ def mpl_style_cb(key): warnings.warn(pc_mpl_style_deprecation_warning, FutureWarning, - stacklevel=4) + stacklevel=5) import sys from pandas.tools.plotting import mpl_stylesheet diff --git a/pandas/tests/test_categorical.py b/pandas/tests/test_categorical.py index 071e280bd112a..9305cabe6bda5 100755 --- a/pandas/tests/test_categorical.py +++ b/pandas/tests/test_categorical.py @@ -4109,7 +4109,8 @@ def test_str_accessor_api_for_categorical(self): ('decode', ("UTF-8",), {}), ('encode', ("UTF-8",), {}), ('endswith', ("a",), {}), - ('extract', ("([a-z]*) ",), {}), + ('extract', ("([a-z]*) ",), {"expand":False}), + ('extract', ("([a-z]*) ",), {"expand":True}), ('extractall', ("([a-z]*) ",), {}), ('find', ("a",), {}), ('findall', ("a",), {}),