From 9fd78590b1588880ba26e34771c1ed6bc504ac8c Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 6 Mar 2020 19:24:39 -0500 Subject: [PATCH] Backport fix for seaborn 0.10.0. --- ...5dfe73b51b55cc90f2140f2cd54a2e7946a0.patch | 126 ++++++++++++++++++ python-xarray.spec | 7 +- 2 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 52ee5dfe73b51b55cc90f2140f2cd54a2e7946a0.patch diff --git a/52ee5dfe73b51b55cc90f2140f2cd54a2e7946a0.patch b/52ee5dfe73b51b55cc90f2140f2cd54a2e7946a0.patch new file mode 100644 index 0000000..f9f0206 --- /dev/null +++ b/52ee5dfe73b51b55cc90f2140f2cd54a2e7946a0.patch @@ -0,0 +1,126 @@ +From 52ee5dfe73b51b55cc90f2140f2cd54a2e7946a0 Mon Sep 17 00:00:00 2001 +From: Mathias Hauser +Date: Wed, 5 Feb 2020 17:03:51 +0100 +Subject: [PATCH] remove seaborn.apionly compatibility (#3749) + +* remove import_seaborn + +* update tests + +* update links + +* add whats new +--- + xarray/plot/utils.py | 22 +--------------------- + xarray/tests/__init__.py | 8 +------- + xarray/tests/test_plot.py | 17 ----------------- + 6 files changed, 8 insertions(+), 47 deletions(-) + +diff --git a/xarray/plot/utils.py b/xarray/plot/utils.py +index 6eec7c6b4..341ff730e 100644 +--- a/xarray/plot/utils.py ++++ b/xarray/plot/utils.py +@@ -21,26 +21,6 @@ + ROBUST_PERCENTILE = 2.0 + + +-def import_seaborn(): +- """import seaborn and handle deprecation of apionly module""" +- with warnings.catch_warnings(record=True) as w: +- warnings.simplefilter("always") +- try: +- import seaborn.apionly as sns +- +- if ( +- w +- and issubclass(w[-1].category, UserWarning) +- and ("seaborn.apionly module" in str(w[-1].message)) +- ): +- raise ImportError +- except ImportError: +- import seaborn as sns +- finally: +- warnings.resetwarnings() +- return sns +- +- + _registered = False + + +@@ -119,7 +99,7 @@ def _color_palette(cmap, n_colors): + except ValueError: + # ValueError happens when mpl doesn't like a colormap, try seaborn + try: +- from seaborn.apionly import color_palette ++ from seaborn import color_palette + + pal = color_palette(cmap, n_colors=n_colors) + except (ValueError, ImportError): +diff --git a/xarray/tests/__init__.py b/xarray/tests/__init__.py +index 6592360cd..df86b5715 100644 +--- a/xarray/tests/__init__.py ++++ b/xarray/tests/__init__.py +@@ -16,7 +16,6 @@ + from xarray.core.duck_array_ops import allclose_or_equiv # noqa: F401 + from xarray.core.indexing import ExplicitlyIndexed + from xarray.core.options import set_options +-from xarray.plot.utils import import_seaborn + + # import mpl and change the backend before other mpl imports + try: +@@ -71,6 +70,7 @@ def LooseVersion(vstring): + has_iris, requires_iris = _importorskip("iris") + has_cfgrib, requires_cfgrib = _importorskip("cfgrib") + has_numbagg, requires_numbagg = _importorskip("numbagg") ++has_seaborn, requires_seaborn = _importorskip("seaborn") + has_sparse, requires_sparse = _importorskip("sparse") + + # some special cases +@@ -78,12 +78,6 @@ def LooseVersion(vstring): + requires_scipy_or_netCDF4 = pytest.mark.skipif( + not has_scipy_or_netCDF4, reason="requires scipy or netCDF4" + ) +-try: +- import_seaborn() +- has_seaborn = True +-except ImportError: +- has_seaborn = False +-requires_seaborn = pytest.mark.skipif(not has_seaborn, reason="requires seaborn") + + # change some global options for tests + set_options(warn_for_unclosed_files=True) +diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py +index 71cb119f0..dda9e5de3 100644 +--- a/xarray/tests/test_plot.py ++++ b/xarray/tests/test_plot.py +@@ -14,7 +14,6 @@ + _build_discrete_cmap, + _color_palette, + _determine_cmap_params, +- import_seaborn, + label_from_attrs, + ) + +@@ -2118,22 +2117,6 @@ def test_ncaxis_notinstalled_line_plot(self): + self.darray.plot.line() + + +-@requires_seaborn +-def test_import_seaborn_no_warning(): +- # GH1633 +- with pytest.warns(None) as record: +- import_seaborn() +- assert len(record) == 0 +- +- +-@requires_matplotlib +-def test_plot_seaborn_no_import_warning(): +- # GH1633 +- with pytest.warns(None) as record: +- _color_palette("Blues", 4) +- assert len(record) == 0 +- +- + test_da_list = [ + DataArray(easy_array((10,))), + DataArray(easy_array((10, 3))), diff --git a/python-xarray.spec b/python-xarray.spec index 1528ce6..57f75b2 100644 --- a/python-xarray.spec +++ b/python-xarray.spec @@ -5,7 +5,7 @@ Name: python-%{srcname} Version: 0.15.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: N-D labeled arrays and datasets in Python License: ASL 2.0 @@ -20,6 +20,8 @@ Patch0002: 0002-DOC-Skip-examples-using-unpackaged-dependencies.patch Patch0003: 0003-DOC-Don-t-print-out-conda-pip-environment.patch # https://github.com/pydata/xarray/pull/3274 Patch0004: 0004-Use-drawstyle-instead-of-linestyle-in-plot.step.patch +# https://github.com/pydata/xarray/pull/3749 +Patch0005: https://github.com/pydata/xarray/commit/52ee5dfe73b51b55cc90f2140f2cd54a2e7946a0.patch BuildArch: noarch @@ -131,6 +133,9 @@ pytest-3 -ra -n auto -m "not network" %changelog +* Fri Mar 06 2020 Elliott Sales de Andrade - 0.15.0-2 +- Backport fix for seaborn 0.10.0 + * Sat Feb 08 2020 Elliott Sales de Andrade - 0.15.0-1 - Update to latest version