-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPS: drop numpy < 1.12 #23062
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
DEPS: drop numpy < 1.12 #23062
Changes from 1 commit
22dab2d
a495db9
124d511
12b9a79
c8bfe66
b2cffb4
e9c407e
aac634d
f18880d
f81ad9f
c29b478
7ecc5f2
6e533e7
2ab7f55
7ca1753
9b85061
5b54612
708b2f6
a41ed9f
1e0c553
317e042
31dc4fa
ec93bdb
d20077a
925b555
b971bfb
93eabad
d72b547
e075eff
305f12b
752b5d7
9dc846a
e7f5bf2
169974b
5b45639
308e943
9be3d10
61763f6
ededd73
079bdaf
162458b
cdd497d
d8587a8
8e37179
d097b43
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 |
---|---|---|
|
@@ -30,10 +30,7 @@ | |
|
||
from pandas.io.formats.printing import pprint_thing | ||
|
||
from pandas.plotting._compat import (_mpl_ge_1_3_1, | ||
_mpl_ge_1_5_0, | ||
_mpl_ge_2_0_0, | ||
_mpl_ge_3_0_0) | ||
from pandas.plotting._compat import _mpl_ge_3_0_0 | ||
from pandas.plotting._style import (plot_params, | ||
_get_standard_colors) | ||
from pandas.plotting._tools import (_subplots, _flatten, table, | ||
|
@@ -551,14 +548,6 @@ def plt(self): | |
import matplotlib.pyplot as plt | ||
return plt | ||
|
||
@staticmethod | ||
def mpl_ge_1_3_1(): | ||
return _mpl_ge_1_3_1() | ||
|
||
@staticmethod | ||
def mpl_ge_1_5_0(): | ||
return _mpl_ge_1_5_0() | ||
|
||
_need_to_set_index = False | ||
|
||
def _get_xticks(self, convert_period=False): | ||
|
@@ -908,8 +897,7 @@ def _make_plot(self): | |
scatter = ax.scatter(data[x].values, data[y].values, c=c_values, | ||
label=label, cmap=cmap, **self.kwds) | ||
if cb: | ||
if self.mpl_ge_1_3_1(): | ||
cbar_label = c if c_is_column else '' | ||
cbar_label = c if c_is_column else '' | ||
self._plot_colorbar(ax, label=cbar_label) | ||
|
||
if label is not None: | ||
|
@@ -1012,10 +1000,9 @@ def _make_plot(self): | |
**kwds) | ||
self._add_legend_handle(newlines[0], label, index=i) | ||
|
||
if not _mpl_ge_2_0_0(): | ||
lines = _get_all_lines(ax) | ||
left, right = _get_xlim(lines) | ||
ax.set_xlim(left, right) | ||
lines = _get_all_lines(ax) | ||
left, right = _get_xlim(lines) | ||
ax.set_xlim(left, right) | ||
|
||
@classmethod | ||
def _plot(cls, ax, x, y, style=None, column_num=None, | ||
|
@@ -1141,8 +1128,7 @@ def _plot(cls, ax, x, y, style=None, column_num=None, | |
|
||
# need to remove label, because subplots uses mpl legend as it is | ||
line_kwds = kwds.copy() | ||
if cls.mpl_ge_1_5_0(): | ||
line_kwds.pop('label') | ||
line_kwds.pop('label') | ||
lines = MPLPlot._plot(ax, x, y_values, style=style, **line_kwds) | ||
|
||
# get data from the line to get coordinates for fill_between | ||
|
@@ -1165,17 +1151,10 @@ def _plot(cls, ax, x, y, style=None, column_num=None, | |
cls._update_stacker(ax, stacking_id, y) | ||
|
||
# LinePlot expects list of artists | ||
res = [rect] if cls.mpl_ge_1_5_0() else lines | ||
res = [rect] | ||
return res | ||
|
||
def _add_legend_handle(self, handle, label, index=None): | ||
if not self.mpl_ge_1_5_0(): | ||
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. The reason this can be removed completely is that after removing the compat stuff, there is no more difference to |
||
from matplotlib.patches import Rectangle | ||
# Because fill_between isn't supported in legend, | ||
# specifically add Rectangle handle here | ||
alpha = self.kwds.get('alpha', None) | ||
handle = Rectangle((0, 0), 1, 1, fc=handle.get_color(), | ||
alpha=alpha) | ||
LinePlot._add_legend_handle(self, handle, label, index=index) | ||
|
||
def _post_plot_logic(self, ax, data): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,12 @@ | |
|
||
import warnings | ||
from contextlib import contextmanager | ||
import re | ||
|
||
import numpy as np | ||
|
||
from pandas.core.dtypes.common import is_list_like | ||
from pandas.compat import lrange, lmap | ||
import pandas.compat as compat | ||
from pandas.plotting._compat import _mpl_ge_2_0_0 | ||
|
||
|
||
def _get_standard_colors(num_colors=None, colormap=None, color_type='default', | ||
|
@@ -72,18 +70,9 @@ def _maybe_valid_colors(colors): | |
# check whether each character can be convertible to colors | ||
maybe_color_cycle = _maybe_valid_colors(list(colors)) | ||
if maybe_single_color and maybe_color_cycle and len(colors) > 1: | ||
# Special case for single str 'CN' match and convert to hex | ||
# for supporting matplotlib < 2.0.0 | ||
if re.match(r'\AC[0-9]\Z', colors) and _mpl_ge_2_0_0(): | ||
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. Think we still need the condition to check the pattern match here, no? 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. It already said under |
||
hex_color = [c['color'] | ||
for c in list(plt.rcParams['axes.prop_cycle'])] | ||
colors = [hex_color[int(colors[1])]] | ||
else: | ||
# this may no longer be required | ||
msg = ("'{0}' can be parsed as both single color and " | ||
"color cycle. Specify each color using a list " | ||
"like ['{0}'] or {1}") | ||
raise ValueError(msg.format(colors, list(colors))) | ||
hex_color = [c['color'] | ||
for c in list(plt.rcParams['axes.prop_cycle'])] | ||
colors = [hex_color[int(colors[1])]] | ||
elif maybe_single_color: | ||
colors = [colors] | ||
else: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ def _ok_for_gaussian_kde(kind): | |
except ImportError: | ||
return False | ||
|
||
return plotting._compat._mpl_ge_1_5_0() | ||
return True | ||
|
||
|
||
@td.skip_if_no_mpl | ||
|
@@ -50,31 +50,14 @@ def setup_method(self, method): | |
import matplotlib as mpl | ||
mpl.rcdefaults() | ||
|
||
self.mpl_le_1_2_1 = plotting._compat._mpl_le_1_2_1() | ||
self.mpl_ge_1_3_1 = plotting._compat._mpl_ge_1_3_1() | ||
self.mpl_ge_1_4_0 = plotting._compat._mpl_ge_1_4_0() | ||
self.mpl_ge_1_5_0 = plotting._compat._mpl_ge_1_5_0() | ||
self.mpl_ge_2_0_0 = plotting._compat._mpl_ge_2_0_0() | ||
self.mpl_ge_2_0_1 = plotting._compat._mpl_ge_2_0_1() | ||
self.mpl_ge_2_2_0 = plotting._compat._mpl_ge_2_2_0() | ||
self.mpl_ge_3_0_0 = plotting._compat._mpl_ge_3_0_0() | ||
|
||
if self.mpl_ge_1_4_0: | ||
self.bp_n_objects = 7 | ||
else: | ||
self.bp_n_objects = 8 | ||
if self.mpl_ge_1_5_0: | ||
# 1.5 added PolyCollections to legend handler | ||
# so we have twice as many items. | ||
self.polycollection_factor = 2 | ||
else: | ||
self.polycollection_factor = 1 | ||
|
||
if self.mpl_ge_2_0_0: | ||
self.default_figsize = (6.4, 4.8) | ||
else: | ||
self.default_figsize = (8.0, 6.0) | ||
self.default_tick_position = 'left' if self.mpl_ge_2_0_0 else 'default' | ||
self.bp_n_objects = 7 | ||
self.polycollection_factor = 2 | ||
self.default_figsize = (6.4, 4.8) | ||
self.default_tick_position = 'left' | ||
|
||
n = 100 | ||
with tm.RNGContext(42): | ||
|
@@ -462,7 +445,7 @@ def _check_box_return_type(self, returned, return_type, expected_keys=None, | |
assert isinstance(value.lines, dict) | ||
elif return_type == 'dict': | ||
line = value['medians'][0] | ||
axes = line.axes if self.mpl_ge_1_5_0 else line.get_axes() | ||
axes = line.axes | ||
if check_ax_title: | ||
assert axes.get_title() == key | ||
else: | ||
|
@@ -510,20 +493,6 @@ def is_grid_on(): | |
obj.plot(kind=kind, grid=True, **kws) | ||
assert is_grid_on() | ||
|
||
def _maybe_unpack_cycler(self, rcParams, field='color'): | ||
""" | ||
Compat layer for MPL 1.5 change to color cycle | ||
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. @WillAyd This sounded like it was only for compat. But I'll add it back in as convenience instead of the list comps |
||
|
||
Before: plt.rcParams['axes.color_cycle'] -> ['b', 'g', 'r'...] | ||
After : plt.rcParams['axes.prop_cycle'] -> cycler(...) | ||
""" | ||
if self.mpl_ge_1_5_0: | ||
cyl = rcParams['axes.prop_cycle'] | ||
colors = [v[field] for v in cyl] | ||
else: | ||
colors = rcParams['axes.color_cycle'] | ||
return colors | ||
|
||
|
||
def _check_plot_works(f, filterwarnings='always', **kwargs): | ||
import matplotlib.pyplot as plt | ||
|
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.
Since mpl has a min version of 2.0.0 don't we still need this check?
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.
That was probably being used incorrectly. I don't think it would apply to 2.0.0 but not 2.0.1.
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 made sure to test all available matplotlib versions, and while the removal of the code for 2.0.0 was an oversight, nothing in the test suite failed. As far as I can tell, 2.0.0 wasn't tested in the CI before, which is also the reason that several if-switches before this PR were strictly speaking wrong (when I removed the compat code in a way that just removed pre-2.0 branches, suddenly there were failures).