From 71866440dcc38bff224a94596612d1cc58a97936 Mon Sep 17 00:00:00 2001 From: dcherian Date: Sun, 29 Jul 2018 11:55:33 -0700 Subject: [PATCH] Revert to using xr.ufuncs --- xarray/plot/plot.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xarray/plot/plot.py b/xarray/plot/plot.py index d51e6b7f908..0b3ab6f1bde 100644 --- a/xarray/plot/plot.py +++ b/xarray/plot/plot.py @@ -479,6 +479,11 @@ def line(self, *args, **kwargs): def _rescale_imshow_rgb(darray, vmin, vmax, robust): assert robust or vmin is not None or vmax is not None + # TODO: remove when min numpy version is bumped to 1.13 + # There's a cyclic dependency via DataArray, so we can't import from + # xarray.ufuncs in global scope. + from xarray.ufuncs import maximum, minimum + # Calculate vmin and vmax automatically for `robust=True` if robust: if vmax is None: @@ -504,7 +509,10 @@ def _rescale_imshow_rgb(darray, vmin, vmax, robust): # After scaling, downcast to 32-bit float. This substantially reduces # memory usage after we hand `darray` off to matplotlib. darray = ((darray.astype('f8') - vmin) / (vmax - vmin)).astype('f4') - return np.minimum(np.maximum(darray, 0), 1) + with warnings.catch_warnings(): + warnings.filterwarnings('ignore', 'xarray.ufuncs', + PendingDeprecationWarning) + return minimum(maximum(darray, 0), 1) def _plot2d(plotfunc):