diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 27d369dd6f7..c1440ec1108 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 ~~~~~~~~~~~~ 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) 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