Skip to content

Commit b155853

Browse files
authored
Turn on html repr by default (pydata#3812)
* Turn on html repr by default * Add By line to release docs * Change tests to expect html as the default display_style
1 parent 8512b7b commit b155853

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

doc/whats-new.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ New Features
3939
often means a user is attempting to pass multiple dimensions to group over
4040
and should instead pass a list.
4141
By `Maximilian Roos <https://github.com/max-sixty>`_
42+
- The new ``Dataset._repr_html_`` and ``DataArray._repr_html_`` (introduced
43+
in 0.14.1) is now on by default. To disable, use
44+
``xarray.set_options(display_style="text")``.
45+
By `Julia Signell <https://github.com/jsignell>`_.
46+
4247

4348
Bug fixes
4449
~~~~~~~~~

xarray/core/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
CMAP_SEQUENTIAL: "viridis",
2121
CMAP_DIVERGENT: "RdBu_r",
2222
KEEP_ATTRS: "default",
23-
DISPLAY_STYLE: "text",
23+
DISPLAY_STYLE: "html",
2424
}
2525

2626
_JOIN_OPTIONS = frozenset(["inner", "outer", "left", "right", "exact"])

xarray/tests/test_options.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ def test_nested_options():
6868

6969

7070
def test_display_style():
71-
original = "text"
71+
original = "html"
7272
assert OPTIONS["display_style"] == original
7373
with pytest.raises(ValueError):
7474
xarray.set_options(display_style="invalid_str")
75-
with xarray.set_options(display_style="html"):
76-
assert OPTIONS["display_style"] == "html"
75+
with xarray.set_options(display_style="text"):
76+
assert OPTIONS["display_style"] == "text"
7777
assert OPTIONS["display_style"] == original
7878

7979

@@ -177,10 +177,11 @@ def test_merge_attr_retention(self):
177177

178178
def test_display_style_text(self):
179179
ds = create_test_dataset_attrs()
180-
text = ds._repr_html_()
181-
assert text.startswith("<pre>")
182-
assert "&#x27;nested&#x27;" in text
183-
assert "&lt;xarray.Dataset&gt;" in text
180+
with xarray.set_options(display_style="text"):
181+
text = ds._repr_html_()
182+
assert text.startswith("<pre>")
183+
assert "&#x27;nested&#x27;" in text
184+
assert "&lt;xarray.Dataset&gt;" in text
184185

185186
def test_display_style_html(self):
186187
ds = create_test_dataset_attrs()
@@ -191,9 +192,10 @@ def test_display_style_html(self):
191192

192193
def test_display_dataarray_style_text(self):
193194
da = create_test_dataarray_attrs()
194-
text = da._repr_html_()
195-
assert text.startswith("<pre>")
196-
assert "&lt;xarray.DataArray &#x27;var1&#x27;" in text
195+
with xarray.set_options(display_style="text"):
196+
text = da._repr_html_()
197+
assert text.startswith("<pre>")
198+
assert "&lt;xarray.DataArray &#x27;var1&#x27;" in text
197199

198200
def test_display_dataarray_style_html(self):
199201
da = create_test_dataarray_attrs()

0 commit comments

Comments
 (0)