Skip to content

Commit

Permalink
Print number of variables in repr (#4762)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Illviljan authored Jan 12, 2021
1 parent 3c1ed20 commit 81ed507
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xarray/core/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ def _mapping_repr(mapping, title, summarizer, col_width=None, max_rows=None):
max_rows = OPTIONS["display_max_rows"]
summary = [f"{title}:"]
if mapping:
if len(mapping) > max_rows:
len_mapping = len(mapping)
if len_mapping > max_rows:
summary = [f"{summary[0]} ({max_rows}/{len_mapping})"]
first_rows = max_rows // 2 + max_rows % 2
items = list(mapping.items())
summary += [summarizer(k, v, col_width) for k, v in items[:first_rows]]
Expand Down

0 comments on commit 81ed507

Please sign in to comment.