Skip to content

API: Restore implicit converter registration #18307

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 26 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
No warnings by default
  • Loading branch information
TomAugspurger committed Nov 30, 2017
commit 04d8aa5021d70aca1684f0ce0b7fdb47e6cfcd56
8 changes: 0 additions & 8 deletions pandas/plotting/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,3 @@ def _mpl_ge_2_1_0():
return matplotlib.__version__ >= LooseVersion('2.1')
except ImportError:
return False


def _mpl_ge_2_2_0():
try:
import matplotlib
return matplotlib.__version__ > LooseVersion('2.1')
except ImportError:
return False
12 changes: 4 additions & 8 deletions pandas/plotting/_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from pandas.core.indexes.period import Period, PeriodIndex

from pandas.plotting._compat import _mpl_le_2_0_0
from pandas.plotting._compat import _mpl_ge_2_2_0

# constants
HOURS_PER_DAY = 24.
Expand All @@ -47,8 +46,8 @@

MUSEC_PER_DAY = 1e6 * SEC_PER_DAY

_WARN = True
_mpl_units = {}
_WARN = True # Global for whether pandas has registered the units explicitly
_mpl_units = {} # Cache for units overwritten by us


def get_pairs():
Expand All @@ -60,12 +59,10 @@ def get_pairs():
(pydt.time, TimeConverter),
(np.datetime64, DatetimeConverter),
]
if _mpl_ge_2_2_0():
pairs = pairs[:2]
return pairs


def register(warn=False):
def register(explicit=False):
"""Register Pandas Formatters and Converters with matplotlib

This function modifies the global ``matplotlib.units.registry``
Expand All @@ -85,11 +82,10 @@ def register(warn=False):
# Renamed in pandas.plotting.__init__
global _WARN

if not warn:
if explicit:
_WARN = False

pairs = get_pairs()
print(pairs)
for type_, cls in pairs:
converter = cls()
if type_ in units.registry:
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
pass
else:
if get_option('plotting.matplotlib.register_converters'):
_converter.register(warn=True)
_converter.register(explicit=True)


def _get_standard_kind(kind):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_registry_resets(self):
units.registry[date] = date_converter

register_matplotlib_converters()
assert not units.registry[date] is date_converter
assert units.registry[date] is date_converter
deregister_matplotlib_converters()
assert units.registry[date] is date_converter

Expand Down