Skip to content

Commit

Permalink
Fix MPL compat again
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Mar 11, 2019
1 parent 5b7099d commit 3550ed4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions pandas/plotting/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def inner():
return inner


_mpl_eq_2_1_0 = _mpl_version('2.1.0', operator.eq)
_mpl_ge_2_1_0 = _mpl_version('2.1.0', operator.ge)
_mpl_eq_2_2_0 = _mpl_version('2.2.0', operator.eq)
_mpl_ge_2_2_0 = _mpl_version('2.2.0', operator.ge)
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/plotting/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def setup_method(self, method):
import matplotlib as mpl
mpl.rcdefaults()

self.mpl_eq_2_1_0 = plotting._compat._mpl_eq_2_1_0()
self.mpl_ge_2_1_0 = plotting._compat._mpl_ge_2_1_0()
self.mpl_eq_2_2_0 = plotting._compat._mpl_eq_2_2_0()
self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0()
Expand Down
40 changes: 20 additions & 20 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,10 @@ def test_get_finder(self):
def test_finder_daily(self):
day_lst = [10, 40, 252, 400, 950, 2750, 10000]

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

Expand All @@ -435,10 +435,10 @@ def test_finder_daily(self):
def test_finder_quarterly(self):
yrs = [3.5, 11]

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

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

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

Expand Down Expand Up @@ -501,10 +501,10 @@ def test_finder_monthly_long(self):

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

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

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

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

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

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

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

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

assert isinstance(data, np.ma.core.MaskedArray)
Expand Down

0 comments on commit 3550ed4

Please sign in to comment.