Skip to content

Commit

Permalink
MPL<3.3 compat in temporal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaskom committed Jun 26, 2022
1 parent ad693ae commit fe3e338
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion seaborn/_core/scales.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 16 additions & 7 deletions tests/_core/test_scales.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Fill,
)
from seaborn.palettes import color_palette
from seaborn.external.version import Version


class TestContinuous:
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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)

0 comments on commit fe3e338

Please sign in to comment.