From 9940c5fa38e39d46239a60468443e93cbf53237e Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Thu, 25 Jun 2020 19:03:25 -0700 Subject: [PATCH 1/3] Show data by default in HTML repr for DataArray Fixes GH-4176 --- xarray/core/formatting_html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/core/formatting_html.py b/xarray/core/formatting_html.py index c99683e91c7..400ef61502e 100644 --- a/xarray/core/formatting_html.py +++ b/xarray/core/formatting_html.py @@ -184,7 +184,7 @@ def dim_section(obj): def array_section(obj): # "unique" id to expand/collapse the section data_id = "section-" + str(uuid.uuid4()) - collapsed = "" + collapsed = "checked" variable = getattr(obj, "variable", obj) preview = escape(inline_variable_array_repr(variable, max_width=70)) data_repr = short_data_repr_html(obj) From d51e92a397f332ac786f53b3312b2aca265049b1 Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Thu, 25 Jun 2020 19:24:53 -0700 Subject: [PATCH 2/3] add whats new for html repr --- doc/whats-new.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index d82be79270e..3fc597cc1a3 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -39,7 +39,9 @@ Breaking changes the default behaviour of :py:func:`open_mfdataset` has changed to use ``combine='by_coords'`` as the default argument value. (:issue:`2616`, :pull:`3926`) By `Tom Nicholas `_. - +- The ``DataArray`` and ``Variable`` HTML reprs now expand the data section by + default (:issue:`4176`) + By `Stephan Hoyer `_. Enhancements ~~~~~~~~~~~~ From 9e8b6817eb1ac527ce67fb6f02e0680edc9b679a Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Thu, 25 Jun 2020 19:33:27 -0700 Subject: [PATCH 3/3] fix test --- xarray/tests/test_formatting_html.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/tests/test_formatting_html.py b/xarray/tests/test_formatting_html.py index ea636403318..9a210ad6fa3 100644 --- a/xarray/tests/test_formatting_html.py +++ b/xarray/tests/test_formatting_html.py @@ -108,8 +108,8 @@ def test_summarize_attrs_with_unsafe_attr_name_and_value(): def test_repr_of_dataarray(dataarray): formatted = fh.array_repr(dataarray) assert "dim_0" in formatted - # has an expandable data section - assert formatted.count("class='xr-array-in' type='checkbox' >") == 1 + # has an expanded data section + assert formatted.count("class='xr-array-in' type='checkbox' checked>") == 1 # coords and attrs don't have an items so they'll be be disabled and collapsed assert ( formatted.count("class='xr-section-summary-in' type='checkbox' disabled >") == 2