Skip to content

Commit 52ee5df

Browse files
authored
remove seaborn.apionly compatibility (#3749)
* remove import_seaborn * update tests * update links * add whats new
1 parent 4c96d53 commit 52ee5df

File tree

6 files changed

+8
-47
lines changed

6 files changed

+8
-47
lines changed

doc/installing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ For plotting
5959

6060
- `matplotlib <http://matplotlib.org/>`__: required for :ref:`plotting`
6161
- `cartopy <http://scitools.org.uk/cartopy/>`__: recommended for :ref:`plot-maps`
62-
- `seaborn <https://stanford.edu/~mwaskom/software/seaborn/>`__: for better
62+
- `seaborn <http://seaborn.pydata.org/>`__: for better
6363
color palettes
6464
- `nc-time-axis <https://github.com/SciTools/nc-time-axis>`__: for plotting
6565
cftime.datetime objects

doc/pandas.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using the visualization `built in to pandas itself`__ or provided by the pandas
1212
aware libraries such as `Seaborn`__.
1313

1414
__ http://pandas.pydata.org/pandas-docs/stable/visualization.html
15-
__ http://stanford.edu/~mwaskom/software/seaborn/
15+
__ http://seaborn.pydata.org/
1616

1717
.. ipython:: python
1818
:suppress:

doc/whats-new.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Documentation
3434
Internal Changes
3535
~~~~~~~~~~~~~~~~
3636

37+
- Removed the internal ``import_seaborn`` function which handled the deprecation of
38+
the ``seaborn.apionly`` entry point (:issue:`3747`).
39+
By `Mathias Hauser <https://github.com/mathause>`_.
40+
3741
.. _whats-new.0.15.0:
3842

3943

xarray/plot/utils.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,6 @@
2121
ROBUST_PERCENTILE = 2.0
2222

2323

24-
def import_seaborn():
25-
"""import seaborn and handle deprecation of apionly module"""
26-
with warnings.catch_warnings(record=True) as w:
27-
warnings.simplefilter("always")
28-
try:
29-
import seaborn.apionly as sns
30-
31-
if (
32-
w
33-
and issubclass(w[-1].category, UserWarning)
34-
and ("seaborn.apionly module" in str(w[-1].message))
35-
):
36-
raise ImportError
37-
except ImportError:
38-
import seaborn as sns
39-
finally:
40-
warnings.resetwarnings()
41-
return sns
42-
43-
4424
_registered = False
4525

4626

@@ -119,7 +99,7 @@ def _color_palette(cmap, n_colors):
11999
except ValueError:
120100
# ValueError happens when mpl doesn't like a colormap, try seaborn
121101
try:
122-
from seaborn.apionly import color_palette
102+
from seaborn import color_palette
123103

124104
pal = color_palette(cmap, n_colors=n_colors)
125105
except (ValueError, ImportError):

xarray/tests/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from xarray.core.duck_array_ops import allclose_or_equiv # noqa: F401
1717
from xarray.core.indexing import ExplicitlyIndexed
1818
from xarray.core.options import set_options
19-
from xarray.plot.utils import import_seaborn
2019

2120
# import mpl and change the backend before other mpl imports
2221
try:
@@ -71,19 +70,14 @@ def LooseVersion(vstring):
7170
has_iris, requires_iris = _importorskip("iris")
7271
has_cfgrib, requires_cfgrib = _importorskip("cfgrib")
7372
has_numbagg, requires_numbagg = _importorskip("numbagg")
73+
has_seaborn, requires_seaborn = _importorskip("seaborn")
7474
has_sparse, requires_sparse = _importorskip("sparse")
7575

7676
# some special cases
7777
has_scipy_or_netCDF4 = has_scipy or has_netCDF4
7878
requires_scipy_or_netCDF4 = pytest.mark.skipif(
7979
not has_scipy_or_netCDF4, reason="requires scipy or netCDF4"
8080
)
81-
try:
82-
import_seaborn()
83-
has_seaborn = True
84-
except ImportError:
85-
has_seaborn = False
86-
requires_seaborn = pytest.mark.skipif(not has_seaborn, reason="requires seaborn")
8781

8882
# change some global options for tests
8983
set_options(warn_for_unclosed_files=True)

xarray/tests/test_plot.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
_build_discrete_cmap,
1515
_color_palette,
1616
_determine_cmap_params,
17-
import_seaborn,
1817
label_from_attrs,
1918
)
2019

@@ -2118,22 +2117,6 @@ def test_ncaxis_notinstalled_line_plot(self):
21182117
self.darray.plot.line()
21192118

21202119

2121-
@requires_seaborn
2122-
def test_import_seaborn_no_warning():
2123-
# GH1633
2124-
with pytest.warns(None) as record:
2125-
import_seaborn()
2126-
assert len(record) == 0
2127-
2128-
2129-
@requires_matplotlib
2130-
def test_plot_seaborn_no_import_warning():
2131-
# GH1633
2132-
with pytest.warns(None) as record:
2133-
_color_palette("Blues", 4)
2134-
assert len(record) == 0
2135-
2136-
21372120
test_da_list = [
21382121
DataArray(easy_array((10,))),
21392122
DataArray(easy_array((10, 3))),

0 commit comments

Comments
 (0)