From 440f08370f2d3ee542a746c6e51c753bb4456de2 Mon Sep 17 00:00:00 2001 From: Julia Signell Date: Thu, 24 Oct 2019 16:21:37 -0400 Subject: [PATCH 1/2] Escaping dtypes --- xarray/core/formatting_html.py | 2 +- xarray/tests/test_formatting_html.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xarray/core/formatting_html.py b/xarray/core/formatting_html.py index b03ecc12962..dbebbcf4fbe 100644 --- a/xarray/core/formatting_html.py +++ b/xarray/core/formatting_html.py @@ -96,7 +96,7 @@ def summarize_variable(name, var, is_index=False, dtype=None, preview=None): cssclass_idx = " class='xr-has-index'" if is_index else "" dims_str = f"({', '.join(escape(dim) for dim in var.dims)})" name = escape(name) - dtype = dtype or var.dtype + dtype = dtype or escape(str(var.dtype)) # "unique" ids required to expand/collapse subsections attrs_id = "attrs-" + str(uuid.uuid4()) diff --git a/xarray/tests/test_formatting_html.py b/xarray/tests/test_formatting_html.py index e7f54b22d06..f7531ce34ea 100644 --- a/xarray/tests/test_formatting_html.py +++ b/xarray/tests/test_formatting_html.py @@ -130,3 +130,5 @@ def test_repr_of_dataset(dataset): assert ( formatted.count("class='xr-section-summary-in' type='checkbox' checked>") == 3 ) + assert '<U4' in formatted + assert '<IA>' in formatted From 89fe8bbd42f5104d095d67c48feef6f8c4f558e9 Mon Sep 17 00:00:00 2001 From: Julia Signell Date: Thu, 24 Oct 2019 16:23:13 -0400 Subject: [PATCH 2/2] Reformatting --- 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 f7531ce34ea..fea24ff93f8 100644 --- a/xarray/tests/test_formatting_html.py +++ b/xarray/tests/test_formatting_html.py @@ -130,5 +130,5 @@ def test_repr_of_dataset(dataset): assert ( formatted.count("class='xr-section-summary-in' type='checkbox' checked>") == 3 ) - assert '<U4' in formatted - assert '<IA>' in formatted + assert "<U4" in formatted + assert "<IA>" in formatted