Skip to content

DEPR: Fixed warning for implicit registration #24964

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

Merged
merged 5 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions doc/source/whatsnew/v0.24.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**

-
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
30 changes: 30 additions & 0 deletions pandas/tests/plotting/test_converter_warning.py
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any easier way to do this? this is introducing massive technical debt.

# 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()