From b6300ea9d9e84e24fc2e03bdff06d8d0659e2344 Mon Sep 17 00:00:00 2001 From: Joe Hamman Date: Tue, 9 Jan 2018 23:13:52 -0800 Subject: [PATCH] Fix/plot error and warning (#1814) * register_matplotlib_converters for pandas 0.22 and later * debug for travis * remove check for np.generic in _valid_other_type (fix for numpy 1.14) * whats new --- doc/whats-new.rst | 5 ++++- xarray/plot/plot.py | 6 ++---- xarray/plot/utils.py | 9 +++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 856ad5e6df7..af53c54dec7 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -74,7 +74,10 @@ Bug fixes - The ``variables``, ``attrs``, and ``dimensions`` properties have been deprecated as part of a bug fix addressing an issue where backends were unintentionally loading the datastores data and attributes repeatedly during - writes (:issue:`1798`). + writes (:issue:`1798`). + By `Joe Hamman `_. +- Compatibility fixes to plotting module for Numpy 1.14 and Pandas 0.22 + (:issue:`1813`). By `Joe Hamman `_. .. _whats-new.0.10.0: diff --git a/xarray/plot/plot.py b/xarray/plot/plot.py index 1bcb60ccd38..19c70961c95 100644 --- a/xarray/plot/plot.py +++ b/xarray/plot/plot.py @@ -37,10 +37,7 @@ def _valid_other_type(x, types): """ Do all elements of x have a type from types? """ - if not np.issubdtype(np.generic, x.dtype): - return False - else: - return all(any(isinstance(el, t) for t in types) for el in np.ravel(x)) + return all(any(isinstance(el, t) for t in types) for el in np.ravel(x)) def _ensure_plottable(*args): @@ -57,6 +54,7 @@ def _ensure_plottable(*args): raise TypeError('Plotting requires coordinates to be numeric ' 'or dates.') + def _easy_facetgrid(darray, plotfunc, x, y, row=None, col=None, col_wrap=None, sharex=True, sharey=True, aspect=None, size=None, subplot_kws=None, **kwargs): diff --git a/xarray/plot/utils.py b/xarray/plot/utils.py index 2ed9c5e3f2a..3d2a633c7dc 100644 --- a/xarray/plot/utils.py +++ b/xarray/plot/utils.py @@ -47,8 +47,13 @@ def register_pandas_datetime_converter_if_needed(): # based on https://github.com/pandas-dev/pandas/pull/17710 global _registered if not _registered: - from pandas.tseries import converter - converter.register() + try: + from pandas.plotting import register_matplotlib_converters + register_matplotlib_converters() + except ImportError: + # register_matplotlib_converters new in pandas 0.22 + from pandas.tseries import converter + converter.register() _registered = True