Skip to content

Commit 3550ed4

Browse files
committed
Fix MPL compat again
1 parent 5b7099d commit 3550ed4

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

pandas/plotting/_compat.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def inner():
1818
return inner
1919

2020

21+
_mpl_eq_2_1_0 = _mpl_version('2.1.0', operator.eq)
2122
_mpl_ge_2_1_0 = _mpl_version('2.1.0', operator.ge)
2223
_mpl_eq_2_2_0 = _mpl_version('2.2.0', operator.eq)
2324
_mpl_ge_2_2_0 = _mpl_version('2.2.0', operator.ge)

pandas/tests/plotting/common.py

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def setup_method(self, method):
5353
import matplotlib as mpl
5454
mpl.rcdefaults()
5555

56+
self.mpl_eq_2_1_0 = plotting._compat._mpl_eq_2_1_0()
5657
self.mpl_ge_2_1_0 = plotting._compat._mpl_ge_2_1_0()
5758
self.mpl_eq_2_2_0 = plotting._compat._mpl_eq_2_2_0()
5859
self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0()

pandas/tests/plotting/test_datetimelike.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,10 @@ def test_get_finder(self):
406406
def test_finder_daily(self):
407407
day_lst = [10, 40, 252, 400, 950, 2750, 10000]
408408

409-
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0:
410-
# 2.2.0 (exactly) or >= 3.0.0
409+
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0 or self.mpl_eq_2_1_0:
410+
# 2.1.0, 2.2.0 (exactly) or >= 3.0.0
411411
xpl1 = xpl2 = [Period('1999-1-1', freq='B').ordinal] * len(day_lst)
412-
else: # 2.1.0, 2.2.2, 2.2.3, 2.2.4
412+
else: # 2.1.2, 2.2.2, 2.2.3, 2.2.4
413413
xpl1 = [7565, 7564, 7553, 7546, 7518, 7428, 7066]
414414
xpl2 = [7566, 7564, 7554, 7546, 7519, 7429, 7066]
415415

@@ -435,10 +435,10 @@ def test_finder_daily(self):
435435
def test_finder_quarterly(self):
436436
yrs = [3.5, 11]
437437

438-
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0:
439-
# 2.2.0 (exactly) or >= 3.0.0
438+
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0 or self.mpl_eq_2_1_0:
439+
# 2.1.0, 2.2.0 (exactly) or >= 3.0.0
440440
xpl1 = xpl2 = [Period('1988Q1').ordinal] * len(yrs)
441-
else: # 2.1.0, 2.2.2, 2.2.3, 2.2.4
441+
else: # 2.1.2, 2.2.2, 2.2.3, 2.2.4
442442
xpl1 = [68, 68]
443443
xpl2 = [72, 68]
444444

@@ -464,10 +464,10 @@ def test_finder_quarterly(self):
464464
def test_finder_monthly(self):
465465
yrs = [1.15, 2.5, 4, 11]
466466

467-
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0:
468-
# 2.2.0 (exactly) or >= 3.0.0
467+
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0 or self.mpl_eq_2_1_0:
468+
# 2.1.0, 2.2.0 (exactly) or >= 3.0.0
469469
xpl1 = xpl2 = [Period('Jan 1988').ordinal] * len(yrs)
470-
else: # 2.1.0, 2.2.2, 2.2.3, 2.2.4
470+
else: # 2.1.2, 2.2.2, 2.2.3, 2.2.4
471471
xpl1 = [216, 216, 204, 204]
472472
xpl2 = [216, 216, 216, 204]
473473

@@ -501,10 +501,10 @@ def test_finder_monthly_long(self):
501501

502502
@pytest.mark.slow
503503
def test_finder_annual(self):
504-
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0:
505-
# 2.2.0 (exactly) or >= 3.0.0
504+
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0 or self.mpl_eq_2_1_0:
505+
# 2.1.0, 2.2.0 (exactly) or >= 3.0.0
506506
xp = [1987, 1988, 1990, 1990, 1995, 2020, 2070, 2170]
507-
else: # 2.1.0, 2.2.2, 2.2.3, 2.2.4
507+
else: # 2.1.2, 2.2.2, 2.2.3, 2.2.4
508508
xp = [1986, 1986, 1990, 1990, 1995, 2020, 1970, 1970]
509509

510510
xp = [Period(x, freq='A').ordinal for x in xp]
@@ -556,8 +556,8 @@ def test_gaps(self):
556556
line = lines[0]
557557
data = line.get_xydata()
558558

559-
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0:
560-
# 2.2.0 (exactly) or >= 3.0.0
559+
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0 or self.mpl_eq_2_1_0:
560+
# 2.1.0, 2.2.0 (exactly) or >= 3.0.0
561561
data = np.ma.MaskedArray(data, mask=isna(data), fill_value=np.nan)
562562

563563
assert isinstance(data, np.ma.core.MaskedArray)
@@ -576,8 +576,8 @@ def test_gaps(self):
576576
line = lines[0]
577577
data = line.get_xydata()
578578

579-
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0:
580-
# 2.2.0 (exactly) or >= 3.0.0
579+
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0 or self.mpl_eq_2_1_0:
580+
# 2.1.0, 2.2.0 (exactly) or >= 3.0.0
581581
data = np.ma.MaskedArray(data, mask=isna(data), fill_value=np.nan)
582582

583583
assert isinstance(data, np.ma.core.MaskedArray)
@@ -595,8 +595,8 @@ def test_gaps(self):
595595
assert len(lines) == 1
596596
line = lines[0]
597597
data = line.get_xydata()
598-
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0:
599-
# 2.2.0 (exactly) or >= 3.0.0
598+
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0 or self.mpl_eq_2_1_0:
599+
# 2.1.0, 2.2.0 (exactly) or >= 3.0.0
600600
data = np.ma.MaskedArray(data, mask=isna(data), fill_value=np.nan)
601601

602602
assert isinstance(data, np.ma.core.MaskedArray)
@@ -619,8 +619,8 @@ def test_gap_upsample(self):
619619

620620
line = lines[0]
621621
data = line.get_xydata()
622-
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0:
623-
# 2.2.0 (exactly) or >= 3.0.0
622+
if self.mpl_ge_3_0_0 or self.mpl_eq_2_2_0 or self.mpl_eq_2_1_0:
623+
# 2.1.0, 2.2.0 (exactly) or >= 3.0.0
624624
data = np.ma.MaskedArray(data, mask=isna(data), fill_value=np.nan)
625625

626626
assert isinstance(data, np.ma.core.MaskedArray)

0 commit comments

Comments
 (0)