From fe3e3383de56d77938dc46627ec0e88767a18e4f Mon Sep 17 00:00:00 2001 From: Michael Waskom Date: Sun, 26 Jun 2022 06:58:23 -0400 Subject: [PATCH] MPL<3.3 compat in temporal tests --- seaborn/_core/scales.py | 2 +- tests/_core/test_scales.py | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/seaborn/_core/scales.py b/seaborn/_core/scales.py index 8fd0bb3c3a..cf3ae2615d 100644 --- a/seaborn/_core/scales.py +++ b/seaborn/_core/scales.py @@ -471,7 +471,7 @@ def label( base : number Use log formatter (with scientific notation) having this value as the base. unit : str or (str, str) tuple - Use engineering formatter with SI units (e.g., with `unit="g"`, a tick value + Use SI prefixes with these units (e.g., with `unit="g"`, a tick value of 5000 will appear as `5 kg`). When a tuple, the first element gives the seperator between the number and unit. diff --git a/tests/_core/test_scales.py b/tests/_core/test_scales.py index b87e84ec0e..57f458554b 100644 --- a/tests/_core/test_scales.py +++ b/tests/_core/test_scales.py @@ -23,6 +23,7 @@ Fill, ) from seaborn.palettes import color_palette +from seaborn.external.version import Version class TestContinuous: @@ -585,6 +586,10 @@ def test_coordinate_axis(self, t, x): assert isinstance(locator, mpl.dates.AutoDateLocator) assert isinstance(formatter, mpl.dates.AutoDateFormatter) + @pytest.mark.skipif( + Version(mpl.__version__) < Version("3.3.0"), + reason="Test requires new matplotlib date epoch." + ) def test_tick_locator(self, t): locator = mpl.dates.YearLocator(month=3, day=15) @@ -601,13 +606,10 @@ def test_tick_upto(self, t, x): locator = ax.xaxis.get_major_locator() assert set(locator.maxticks.values()) == {n} - def test_label_concise(self, t, x): - - ax = mpl.figure.Figure().subplots() - Temporal().label(concise=True)._setup(t, Coordinate(), ax.xaxis) - formatter = ax.xaxis.get_major_formatter() - assert isinstance(formatter, mpl.dates.ConciseDateFormatter) - + @pytest.mark.skipif( + Version(mpl.__version__) < Version("3.3.0"), + reason="Test requires new matplotlib date epoch." + ) def test_label_formatter(self, t): formatter = mpl.dates.DateFormatter("%Y") @@ -616,3 +618,10 @@ def test_label_formatter(self, t): a.set_view_interval(10, 1000) label, = a.major.formatter.format_ticks([100]) assert label == "1970" + + def test_label_concise(self, t, x): + + ax = mpl.figure.Figure().subplots() + Temporal().label(concise=True)._setup(t, Coordinate(), ax.xaxis) + formatter = ax.xaxis.get_major_formatter() + assert isinstance(formatter, mpl.dates.ConciseDateFormatter)