From a573aaedd7af11ae48f776b85de9caee88f4ac40 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 17 Aug 2021 15:55:51 +0200 Subject: [PATCH 1/4] Update test_plot.py --- xarray/tests/test_plot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index e358bd47485..5eb5e3d4a89 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -2952,6 +2952,7 @@ def test_datarray_scatter(x, y, z, hue, markersize, row, col, add_legend, add_co ) +@requires_matplotlib def test_latex_name_isnt_split(): da = xr.DataArray() long_latex_name = r"$Ra_s = \mathrm{mean}(\epsilon_k) / \mu M^2_\infty$" From 8815cf1c4a799f6d5030d0d20ee29efc45057269 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:13:17 +0200 Subject: [PATCH 2/4] crashes ubuntu-latest py37-bare-minimum now? --- xarray/tests/test_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index 5eb5e3d4a89..05f8277e600 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -2952,7 +2952,7 @@ def test_datarray_scatter(x, y, z, hue, markersize, row, col, add_legend, add_co ) -@requires_matplotlib +# @requires_matplotlib def test_latex_name_isnt_split(): da = xr.DataArray() long_latex_name = r"$Ra_s = \mathrm{mean}(\epsilon_k) / \mu M^2_\infty$" From 6ba3f9f3d4f8914bbc3f7b008f33b68ecaed621a Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:20:09 +0200 Subject: [PATCH 3/4] Yes it did crash the ci as expected. --- xarray/tests/test_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index 05f8277e600..5eb5e3d4a89 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -2952,7 +2952,7 @@ def test_datarray_scatter(x, y, z, hue, markersize, row, col, add_legend, add_co ) -# @requires_matplotlib +@requires_matplotlib def test_latex_name_isnt_split(): da = xr.DataArray() long_latex_name = r"$Ra_s = \mathrm{mean}(\epsilon_k) / \mu M^2_\infty$" From f12d9327aa2aa1b5384cf7759658798a72ea4876 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 17 Aug 2021 17:33:37 +0200 Subject: [PATCH 4/4] move to test_label_from_attrs --- xarray/tests/test_plot.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index 5eb5e3d4a89..0c4dd5a29f2 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -185,6 +185,11 @@ def test_label_from_attrs(self): da.attrs.pop("units") assert "a" == label_from_attrs(da) + # Latex strings can be longer without needing a new line: + long_latex_name = r"$Ra_s = \mathrm{mean}(\epsilon_k) / \mu M^2_\infty$" + da.attrs = dict(long_name=long_latex_name) + assert label_from_attrs(da) == long_latex_name + def test1d(self): self.darray[:, 0, 0].plot() @@ -2950,11 +2955,3 @@ def test_datarray_scatter(x, y, z, hue, markersize, row, col, add_legend, add_co add_legend=add_legend, add_colorbar=add_colorbar, ) - - -@requires_matplotlib -def test_latex_name_isnt_split(): - da = xr.DataArray() - long_latex_name = r"$Ra_s = \mathrm{mean}(\epsilon_k) / \mu M^2_\infty$" - da.attrs = dict(long_name=long_latex_name) - assert label_from_attrs(da) == long_latex_name