From e54b388d76d85a66dbe744b9cf540d6469060fe7 Mon Sep 17 00:00:00 2001 From: s-weigand Date: Sat, 6 Nov 2021 21:25:47 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20format=5Fitem=20crash=20wh?= =?UTF-8?q?en=20value=20array=20of=20shape=20(1,=20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xarray/core/formatting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py index ab1cde860f9..3f65cce4f68 100644 --- a/xarray/core/formatting.py +++ b/xarray/core/formatting.py @@ -143,7 +143,7 @@ def format_item(x, timedelta_format=None, quote_strings=True): elif isinstance(x, (str, bytes)): return repr(x) if quote_strings else x elif hasattr(x, "dtype") and np.issubdtype(x.dtype, np.floating): - return f"{x:.4}" + return f"{x.item():.4}" else: return str(x)