Skip to content

Commit 81ed507

Browse files
authored
Print number of variables in repr (#4762)
* Print number of variables in repr * Tweak title only when there's many rows Workaround to avoid having to redo every single doctest... It is really only necessary when the data rows are limited. But I find it a bit difficult to count the rows quickly past like 7. * Remove min() No need to limit max_rows now because the if condition handles that.
1 parent 3c1ed20 commit 81ed507

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

xarray/core/formatting.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,9 @@ def _mapping_repr(mapping, title, summarizer, col_width=None, max_rows=None):
372372
max_rows = OPTIONS["display_max_rows"]
373373
summary = [f"{title}:"]
374374
if mapping:
375-
if len(mapping) > max_rows:
375+
len_mapping = len(mapping)
376+
if len_mapping > max_rows:
377+
summary = [f"{summary[0]} ({max_rows}/{len_mapping})"]
376378
first_rows = max_rows // 2 + max_rows % 2
377379
items = list(mapping.items())
378380
summary += [summarizer(k, v, col_width) for k, v in items[:first_rows]]

0 commit comments

Comments
 (0)