Skip to content

Commit

Permalink
Fix/plot error and warning (pydata#1814)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Joe Hamman authored and shoyer committed Jan 10, 2018
1 parent ab0db05 commit b6300ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/jhamman>`_.
- Compatibility fixes to plotting module for Numpy 1.14 and Pandas 0.22
(:issue:`1813`).
By `Joe Hamman <https://github.com/jhamman>`_.

.. _whats-new.0.10.0:
Expand Down
6 changes: 2 additions & 4 deletions xarray/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
9 changes: 7 additions & 2 deletions xarray/plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit b6300ea

Please sign in to comment.