From 2329aa4a0041366ded83bf0ec56b1a79ff362a50 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Thu, 22 Aug 2024 13:41:05 -0600 Subject: [PATCH] MNT: Work around pydata/xarray#9043 Add some item() calls to get true scalars to pass for image extent in declarative. --- src/metpy/plots/declarative.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/metpy/plots/declarative.py b/src/metpy/plots/declarative.py index 843c82d92b6..614707b90ee 100644 --- a/src/metpy/plots/declarative.py +++ b/src/metpy/plots/declarative.py @@ -1012,7 +1012,9 @@ def _build(self): # If we're on a map, we use min/max for y and manually figure out origin to try to # avoid upside down images created by images where y[0] > y[-1], as well as # specifying the transform - kwargs['extent'] = (x_like[0], x_like[-1], y_like.min(), y_like.max()) + # TODO item() shouldn't be necessary, but is until pydata/xarray#9043 is fixed. + kwargs['extent'] = (x_like[0].item(), x_like[-1].item(), + y_like.min().item(), y_like.max().item()) kwargs['origin'] = 'upper' if y_like[0] > y_like[-1] else 'lower' kwargs.setdefault('cmap', self._cmap_obj) kwargs.setdefault('norm', self._norm_obj)