Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show data by default in HTML repr for DataArray #4182

Merged
merged 3 commits into from
Jun 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/TomNicholas>`_.

- The ``DataArray`` and ``Variable`` HTML reprs now expand the data section by
default (:issue:`4176`)
By `Stephan Hoyer <https://github.com/shoyer>`_.

Enhancements
~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/formatting_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions xarray/tests/test_formatting_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down