From b8bfb50f92ded202056109ac4ac33b1fe18b6331 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Sun, 27 Jan 2019 15:29:12 -0600 Subject: [PATCH 1/4] DEPR: Fixed warning for implicit registration --- ci/run_tests.sh | 4 +++ doc/source/whatsnew/v0.24.1.rst | 5 ++++ pandas/plotting/_core.py | 2 +- .../tests/plotting/test_converter_warning.py | 30 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 pandas/tests/plotting/test_converter_warning.py diff --git a/ci/run_tests.sh b/ci/run_tests.sh index ee46da9f52eab..17ca072512e64 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -56,3 +56,7 @@ do bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME fi done + +# TODO: Remove this and tests/plotting/test_converter_warns.py +echo "Running test_converter_warns.py" +python pandas/tests/plotting/test_converter_warns.py diff --git a/doc/source/whatsnew/v0.24.1.rst b/doc/source/whatsnew/v0.24.1.rst index 3ac2ed73ea53f..8be1825ac09da 100644 --- a/doc/source/whatsnew/v0.24.1.rst +++ b/doc/source/whatsnew/v0.24.1.rst @@ -67,6 +67,11 @@ Bug Fixes - Bug in :func:`merge` when merging by index name would sometimes result in an incorrectly numbered index (:issue:`24212`) +**Visualization** + +- Fixed the warning for implicitly registered matplotlib converters not showing. See :ref:`whatsnew_0211.converters` for more (:issue:`24963`). + + **Other** - diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index e543ab88f53b2..85549bafa8dc0 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -39,7 +39,7 @@ else: _HAS_MPL = True if get_option('plotting.matplotlib.register_converters'): - _converter.register(explicit=True) + _converter.register(explicit=False) def _raise_if_no_mpl(): diff --git a/pandas/tests/plotting/test_converter_warning.py b/pandas/tests/plotting/test_converter_warning.py new file mode 100644 index 0000000000000..546f1d7dc1a1a --- /dev/null +++ b/pandas/tests/plotting/test_converter_warning.py @@ -0,0 +1,30 @@ +# This test ensure that we warn for implicitly registered converters. +# We isolate it completely, because its behavior depends on some global state +# set at import time, which is tricky to get right. +# We use unittest instead of pytest, since pytest will import pandas when +# loading our conftest.py +# https://github.com/pandas-dev/pandas/issues/24963 +# https://github.com/pandas-dev/pandas/pull/18307 +# TODO: Remove the special runner in ci/run_tests.sh +import sys +import unittest + + +class TestConverter(unittest.TestCase): + @unittest.skipIf("pandas" in sys.modules, "pandas musn't be imported.") + def test_converter_warning(self): + import pandas as pd + import pandas.util.testing as tm + try: + import matplotlib.pyplot as plt + except ImportError: + return unittest.skip("No matplotlib") + + fig, ax = plt.subplots() + ser = pd.Series(range(12), index=pd.date_range('2000', periods=12)) + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): + ax.plot(ser) + + +if __name__ == '__main__': + unittest.main() From 8a84ea59d8e9750838819dba92e6543fc23a4dac Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 28 Jan 2019 07:25:52 -0600 Subject: [PATCH 2/4] fixed name --- .../{test_converter_warning.py => test_converter_warns.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pandas/tests/plotting/{test_converter_warning.py => test_converter_warns.py} (100%) diff --git a/pandas/tests/plotting/test_converter_warning.py b/pandas/tests/plotting/test_converter_warns.py similarity index 100% rename from pandas/tests/plotting/test_converter_warning.py rename to pandas/tests/plotting/test_converter_warns.py From 74560f2e9c8b949d1998bb9ef338c89a620766fa Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 28 Jan 2019 08:15:06 -0600 Subject: [PATCH 3/4] skip py2 --- ci/run_tests.sh | 2 +- pandas/tests/plotting/test_converter_warns.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 17ca072512e64..25631314dda95 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -59,4 +59,4 @@ done # TODO: Remove this and tests/plotting/test_converter_warns.py echo "Running test_converter_warns.py" -python pandas/tests/plotting/test_converter_warns.py +python pandas/tests/plotting/test_converter_warns.py -v diff --git a/pandas/tests/plotting/test_converter_warns.py b/pandas/tests/plotting/test_converter_warns.py index 546f1d7dc1a1a..47270f0ff17ca 100644 --- a/pandas/tests/plotting/test_converter_warns.py +++ b/pandas/tests/plotting/test_converter_warns.py @@ -11,6 +11,7 @@ class TestConverter(unittest.TestCase): + @unittest.skipIf(sys.version_info[0] == 2, "CI Failure") @unittest.skipIf("pandas" in sys.modules, "pandas musn't be imported.") def test_converter_warning(self): import pandas as pd @@ -18,7 +19,7 @@ def test_converter_warning(self): try: import matplotlib.pyplot as plt except ImportError: - return unittest.skip("No matplotlib") + raise unittest.SkipTest("No matplotlib") fig, ax = plt.subplots() ser = pd.Series(range(12), index=pd.date_range('2000', periods=12)) From d4b4d3ef46654a35527531c81dc240c195a0124f Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 28 Jan 2019 20:51:33 -0600 Subject: [PATCH 4/4] remove tests --- ci/run_tests.sh | 4 --- pandas/tests/plotting/test_converter_warns.py | 31 ------------------- 2 files changed, 35 deletions(-) delete mode 100644 pandas/tests/plotting/test_converter_warns.py diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 25631314dda95..ee46da9f52eab 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -56,7 +56,3 @@ do bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME fi done - -# TODO: Remove this and tests/plotting/test_converter_warns.py -echo "Running test_converter_warns.py" -python pandas/tests/plotting/test_converter_warns.py -v diff --git a/pandas/tests/plotting/test_converter_warns.py b/pandas/tests/plotting/test_converter_warns.py deleted file mode 100644 index 47270f0ff17ca..0000000000000 --- a/pandas/tests/plotting/test_converter_warns.py +++ /dev/null @@ -1,31 +0,0 @@ -# This test ensure that we warn for implicitly registered converters. -# We isolate it completely, because its behavior depends on some global state -# set at import time, which is tricky to get right. -# We use unittest instead of pytest, since pytest will import pandas when -# loading our conftest.py -# https://github.com/pandas-dev/pandas/issues/24963 -# https://github.com/pandas-dev/pandas/pull/18307 -# TODO: Remove the special runner in ci/run_tests.sh -import sys -import unittest - - -class TestConverter(unittest.TestCase): - @unittest.skipIf(sys.version_info[0] == 2, "CI Failure") - @unittest.skipIf("pandas" in sys.modules, "pandas musn't be imported.") - def test_converter_warning(self): - import pandas as pd - import pandas.util.testing as tm - try: - import matplotlib.pyplot as plt - except ImportError: - raise unittest.SkipTest("No matplotlib") - - fig, ax = plt.subplots() - ser = pd.Series(range(12), index=pd.date_range('2000', periods=12)) - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - ax.plot(ser) - - -if __name__ == '__main__': - unittest.main()