Skip to content

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

Merged
merged 45 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
22dab2d
DEPS: drop numpy < 1.12
h-vetinari Oct 9, 2018
a495db9
Drop bottleneck < 1.2.0
h-vetinari Oct 9, 2018
124d511
Drop matplotlib < 2.0.0
h-vetinari Oct 9, 2018
12b9a79
Drop numexpr < 2.6.2
h-vetinari Oct 9, 2018
c8bfe66
Remove mpl compat code
h-vetinari Oct 9, 2018
b2cffb4
Remove redundant functions
h-vetinari Oct 9, 2018
e9c407e
Reinstante _unpack_cycler
h-vetinari Oct 10, 2018
aac634d
Drop pytables < 3.4.2
h-vetinari Oct 10, 2018
f18880d
Bump numpy requirement in install.py
h-vetinari Oct 10, 2018
f81ad9f
Add output for debugging tests/plotting/test_datetimelike
h-vetinari Oct 10, 2018
c29b478
Drop scipy < 0.18.1
h-vetinari Oct 10, 2018
7ecc5f2
Fix debugging output
h-vetinari Oct 10, 2018
6e533e7
Reduce min version for numexpr/pytables after conda investigation
h-vetinari Oct 10, 2018
2ab7f55
Review (jreback & jbrockmendel)
h-vetinari Oct 10, 2018
7ca1753
Next iteration debugging tests/plotting/test_datetimelike
h-vetinari Oct 10, 2018
9b85061
Spread matplotlib-version in CI for debugging
h-vetinari Oct 10, 2018
5b54612
Re-drop pytables < 3.4.2
h-vetinari Oct 10, 2018
708b2f6
Remove non-existent version
h-vetinari Oct 10, 2018
a41ed9f
Debugggggg
h-vetinari Oct 10, 2018
1e0c553
Fix typos
h-vetinari Oct 10, 2018
317e042
More mpl compat
h-vetinari Oct 10, 2018
31dc4fa
Revert xfails for missing MaskedArrays
h-vetinari Oct 10, 2018
ec93bdb
Clean up diff/switches in test_datetimelike
h-vetinari Oct 11, 2018
d20077a
Fix wording
h-vetinari Oct 11, 2018
925b555
Review (jreback)
h-vetinari Oct 11, 2018
b971bfb
Last round of mpl debugging
h-vetinari Oct 11, 2018
93eabad
Tiny fix
h-vetinari Oct 11, 2018
d72b547
Revert debugging helpers
h-vetinari Oct 11, 2018
e075eff
Partially revert mpl-pins used for debugging
h-vetinari Oct 11, 2018
305f12b
Merge remote-tracking branch 'upstream/master' into bump_numpy
h-vetinari Oct 11, 2018
752b5d7
Rename azure containers
h-vetinari Oct 11, 2018
9dc846a
Bump numexpr check
h-vetinari Oct 12, 2018
e7f5bf2
Merge remote-tracking branch 'upstream/master' into bump_numpy
h-vetinari Oct 12, 2018
169974b
Try retrigger CircleCI
h-vetinari Oct 12, 2018
5b45639
Better error log for failing tests
h-vetinari Oct 12, 2018
308e943
Debugging azure macos build
h-vetinari Oct 12, 2018
9be3d10
Revert "Partially revert mpl-pins used for debugging"
h-vetinari Oct 12, 2018
61763f6
Final debug???
h-vetinari Oct 12, 2018
ededd73
shift debugging pin away from doc build
h-vetinari Oct 12, 2018
079bdaf
MPLMPLMPLMPLMPLMPLMPLMPLMPLMPLMPL
h-vetinari Oct 12, 2018
162458b
Revert "shift debugging pin away from doc build"
h-vetinari Oct 12, 2018
cdd497d
Revert "Revert "Partially revert mpl-pins used for debugging""
h-vetinari Oct 12, 2018
d8587a8
Merge branch 'master' into bump_numpy
h-vetinari Oct 14, 2018
8e37179
Retrigger CI
h-vetinari Oct 14, 2018
d097b43
Merge remote-tracking branch 'upstream/master' into bump_numpy
h-vetinari Oct 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions pandas/plotting/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ def inner():
return inner


_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)
Expand Down
9 changes: 0 additions & 9 deletions pandas/plotting/_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
from pandas.tseries.frequencies import FreqGroup
from pandas.core.indexes.period import Period, PeriodIndex

from pandas.plotting._compat import _mpl_le_2_0_0

# constants
HOURS_PER_DAY = 24.
MIN_PER_HOUR = 60.
Expand Down Expand Up @@ -371,13 +369,6 @@ def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
if self._tz is dates.UTC:
self._tz._utcoffset = self._tz.utcoffset(None)

# For mpl > 2.0 the format strings are controlled via rcparams
# so do not mess with them. For mpl < 2.0 change the second
# break point and add a musec break point
if _mpl_le_2_0_0():
Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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).

self.scaled[1. / SEC_PER_DAY] = '%H:%M:%S'
self.scaled[1. / MUSEC_PER_DAY] = '%H:%M:%S.%f'


class PandasAutoDateLocator(dates.AutoDateLocator):

Expand Down
35 changes: 7 additions & 28 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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():
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 _add_legend_handle of LinePlot, which AreaPlot inherits from

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):
Expand Down
17 changes: 3 additions & 14 deletions pandas/plotting/_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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():
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already said under else that "this may no longer be required". So I wanted to see if removing it still passes the test suite

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:
Expand Down
43 changes: 6 additions & 37 deletions pandas/tests/plotting/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
15 changes: 2 additions & 13 deletions pandas/tests/plotting/test_boxplot_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest
import itertools
import string
from distutils.version import LooseVersion

from pandas import Series, DataFrame, MultiIndex
from pandas.compat import range, lzip
Expand All @@ -21,15 +20,6 @@
""" Test cases for .boxplot method """


def _skip_if_mpl_14_or_dev_boxplot():
# GH 8382
# Boxplot failures on 1.4 and 1.4.1
# Don't need try / except since that's done at class level
import matplotlib
if LooseVersion(matplotlib.__version__) >= LooseVersion('1.4'):
pytest.skip("Matplotlib Regression in 1.4 and current dev.")


@td.skip_if_no_mpl
class TestDataFramePlots(TestPlotBase):

Expand Down Expand Up @@ -71,12 +61,12 @@ def test_boxplot_legacy2(self):
# passed ax should be used:
fig, ax = self.plt.subplots()
axes = df.boxplot('Col1', by='X', ax=ax)
ax_axes = ax.axes if self.mpl_ge_1_5_0 else ax.get_axes()
ax_axes = ax.axes
assert ax_axes is axes

fig, ax = self.plt.subplots()
axes = df.groupby('Y').boxplot(ax=ax, return_type='axes')
ax_axes = ax.axes if self.mpl_ge_1_5_0 else ax.get_axes()
ax_axes = ax.axes
assert ax_axes is axes['A']

# Multiple columns with an ax argument should use same figure
Expand Down Expand Up @@ -155,7 +145,6 @@ def _check_ax_limits(col, ax):

@pytest.mark.slow
def test_boxplot_empty_column(self):
_skip_if_mpl_14_or_dev_boxplot()
df = DataFrame(np.random.randn(20, 4))
df.loc[:, 0] = np.nan
_check_plot_works(df.boxplot, return_type='axes')
Expand Down
Loading