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

Turn on html repr by default #3812

Merged
merged 3 commits into from
Mar 2, 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
5 changes: 5 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ New Features
often means a user is attempting to pass multiple dimensions to group over
and should instead pass a list.
By `Maximilian Roos <https://github.com/max-sixty>`_
- The new ``Dataset._repr_html_`` and ``DataArray._repr_html_`` (introduced
in 0.14.1) is now on by default. To disable, use
``xarray.set_options(display_style="text")``.
jsignell marked this conversation as resolved.
Show resolved Hide resolved
By `Julia Signell <https://github.com/jsignell>`_.


Bug fixes
~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
CMAP_SEQUENTIAL: "viridis",
CMAP_DIVERGENT: "RdBu_r",
KEEP_ATTRS: "default",
DISPLAY_STYLE: "text",
DISPLAY_STYLE: "html",
}

_JOIN_OPTIONS = frozenset(["inner", "outer", "left", "right", "exact"])
Expand Down
22 changes: 12 additions & 10 deletions xarray/tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ def test_nested_options():


def test_display_style():
original = "text"
original = "html"
assert OPTIONS["display_style"] == original
with pytest.raises(ValueError):
xarray.set_options(display_style="invalid_str")
with xarray.set_options(display_style="html"):
assert OPTIONS["display_style"] == "html"
with xarray.set_options(display_style="text"):
assert OPTIONS["display_style"] == "text"
assert OPTIONS["display_style"] == original


Expand Down Expand Up @@ -177,10 +177,11 @@ def test_merge_attr_retention(self):

def test_display_style_text(self):
ds = create_test_dataset_attrs()
text = ds._repr_html_()
assert text.startswith("<pre>")
assert "&#x27;nested&#x27;" in text
assert "&lt;xarray.Dataset&gt;" in text
with xarray.set_options(display_style="text"):
text = ds._repr_html_()
assert text.startswith("<pre>")
assert "&#x27;nested&#x27;" in text
assert "&lt;xarray.Dataset&gt;" in text

def test_display_style_html(self):
ds = create_test_dataset_attrs()
Expand All @@ -191,9 +192,10 @@ def test_display_style_html(self):

def test_display_dataarray_style_text(self):
da = create_test_dataarray_attrs()
text = da._repr_html_()
assert text.startswith("<pre>")
assert "&lt;xarray.DataArray &#x27;var1&#x27;" in text
with xarray.set_options(display_style="text"):
text = da._repr_html_()
assert text.startswith("<pre>")
assert "&lt;xarray.DataArray &#x27;var1&#x27;" in text

def test_display_dataarray_style_html(self):
da = create_test_dataarray_attrs()
Expand Down