Skip to content

Commit

Permalink
🩹 Fix format_item crash when value array of shape (1, )
Browse files Browse the repository at this point in the history
  • Loading branch information
s-weigand committed Nov 6, 2021
1 parent d058db9 commit e54b388
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xarray/core/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit e54b388

Please sign in to comment.