Skip to content
forked from pydata/xarray

Commit

Permalink
Revert to using xr.ufuncs
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Aug 20, 2018
1 parent 7518bd7 commit 7186644
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion xarray/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 7186644

Please sign in to comment.