-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
COMPAT: Matplotlib 2.2 compatability #20079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
01864d0
f028546
5380375
456f7f5
f284ffe
ef0d6ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,31 @@ | ||
# being a bit too dynamic | ||
# pylint: disable=E1101 | ||
from __future__ import division | ||
import operator | ||
|
||
from distutils.version import LooseVersion | ||
|
||
|
||
def _mpl_le_1_2_1(): | ||
try: | ||
import matplotlib as mpl | ||
return (LooseVersion(mpl.__version__) <= LooseVersion('1.2.1') and | ||
def _mpl_version(version, op): | ||
def inner(): | ||
try: | ||
import matplotlib as mpl | ||
except ImportError: | ||
return False | ||
return (op(LooseVersion(mpl.__version__), LooseVersion(version)) and | ||
str(mpl.__version__)[0] != '0') | ||
except ImportError: | ||
return False | ||
|
||
return inner | ||
|
||
def _mpl_ge_1_3_1(): | ||
try: | ||
import matplotlib | ||
# The or v[0] == '0' is because their versioneer is | ||
# messed up on dev | ||
return (LooseVersion(matplotlib.__version__) >= | ||
LooseVersion('1.3.1') or | ||
str(matplotlib.__version__)[0] == '0') | ||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_ge_1_4_0(): | ||
try: | ||
import matplotlib | ||
return (LooseVersion(matplotlib.__version__) >= LooseVersion('1.4') or | ||
str(matplotlib.__version__)[0] == '0') | ||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_ge_1_5_0(): | ||
try: | ||
import matplotlib | ||
return (LooseVersion(matplotlib.__version__) >= LooseVersion('1.5') or | ||
str(matplotlib.__version__)[0] == '0') | ||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_ge_2_0_0(): | ||
try: | ||
import matplotlib | ||
return LooseVersion(matplotlib.__version__) >= LooseVersion('2.0') | ||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_le_2_0_0(): | ||
try: | ||
import matplotlib | ||
return matplotlib.compare_versions('2.0.0', matplotlib.__version__) | ||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_ge_2_0_1(): | ||
try: | ||
import matplotlib | ||
return LooseVersion(matplotlib.__version__) >= LooseVersion('2.0.1') | ||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_ge_2_1_0(): | ||
try: | ||
import matplotlib | ||
return LooseVersion(matplotlib.__version__) >= LooseVersion('2.1') | ||
except ImportError: | ||
return False | ||
_mpl_ge_1_2_1 = _mpl_version('1.2.1', operator.ge) | ||
_mpl_le_1_2_1 = _mpl_version('1.2.1', operator.le) | ||
_mpl_ge_1_3_1 = _mpl_version('1.3.1', operator.ge) | ||
_mpl_ge_1_4_0 = _mpl_version('1.4.0', operator.ge) | ||
_mpl_ge_1_4_1 = _mpl_version('1.4.1', operator.ge) | ||
_mpl_ge_1_5_0 = _mpl_version('1.5.0', operator.ge) | ||
_mpl_ge_2_0_0 = _mpl_version('2.0.0', operator.ge) | ||
_mpl_le_2_0_0 = _mpl_version('2.0.0', operator.le) | ||
_mpl_ge_2_0_1 = _mpl_version('2.0.1', operator.ge) | ||
_mpl_ge_2_1_0 = _mpl_version('2.1.0', operator.ge) | ||
_mpl_ge_2_2_0 = _mpl_version('2.2.0', operator.ge) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
import numpy as np | ||
from pandas import Index, Series, DataFrame, NaT | ||
from pandas.compat import is_platform_mac, PY3 | ||
from pandas.compat import PY3 | ||
from pandas.core.indexes.datetimes import date_range, bdate_range | ||
from pandas.core.indexes.timedeltas import timedelta_range | ||
from pandas.tseries.offsets import DateOffset | ||
|
@@ -1357,13 +1357,13 @@ def test_plot_outofbounds_datetime(self): | |
values = [datetime(1677, 1, 1, 12), datetime(1677, 1, 2, 12)] | ||
ax.plot(values) | ||
|
||
@td.xfail_if_mpl_2_2 | ||
@pytest.mark.skip( | ||
is_platform_mac(), | ||
"skip on mac for precision display issue on older mpl") | ||
def test_format_timedelta_ticks_narrow(self): | ||
|
||
if self.mpl_ge_2_0_0: | ||
if self.mpl_ge_2_2_0: | ||
expected_labels = (['-1 days 23:59:59.999999998'] + | ||
['00:00:00.0000000{:0>2d}'.format(2 * i) | ||
for i in range(6)]) | ||
elif self.mpl_ge_2_0_0: | ||
expected_labels = [''] + [ | ||
'00:00:00.00000000{:d}'.format(2 * i) | ||
for i in range(5)] + [''] | ||
|
@@ -1382,10 +1382,6 @@ def test_format_timedelta_ticks_narrow(self): | |
for l, l_expected in zip(labels, expected_labels): | ||
assert l.get_text() == l_expected | ||
|
||
@td.xfail_if_mpl_2_2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we originally had the mac skips on here (e.g. before 2.2). not really sure if they are still relevant though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm testing on a mac, so hopefully we're OK. |
||
@pytest.mark.skip( | ||
is_platform_mac(), | ||
"skip on mac for precision display issue on older mpl") | ||
def test_format_timedelta_ticks_wide(self): | ||
|
||
if self.mpl_ge_2_0_0: | ||
|
@@ -1402,6 +1398,9 @@ def test_format_timedelta_ticks_wide(self): | |
'9 days 06:13:20', | ||
'' | ||
] | ||
if self.mpl_ge_2_2_0: | ||
expected_labels[0] = '-2 days 20:13:20' | ||
expected_labels[-1] = '10 days 10:00:00' | ||
else: | ||
expected_labels = [ | ||
'00:00:00', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll think I'll remove this just before merging. Other than table, which is broken for py27, there weren't any comparability issues.