8000 Merge pull request #6 from tacaswell/unpack_labeled_data_alternative · astrofrog/matplotlib@5fbe4b0 · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 5fbe4b0

Browse files
committed
Merge pull request matplotlib#6 from tacaswell/unpack_labeled_data_alternative
More fixes
2 parents 59f3917 + 0734b86 commit 5fbe4b0

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

boilerplate.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,7 @@ def format_value(value):
212212
# Get argspec of wrapped function
213213
base_func = getattr(Axes, func)
214214
has_data = 'data' in inspect.signature(base_func).parameters
215-
if hasattr(base_func, '__wrapped__'):
216-
work_func = base_func.__wrapped__
217-
else:
218-
work_func = base_func
215+
work_func = inspect.unwrap(base_func)
219216

220217
args, varargs, varkw, defaults = inspect.getargspec(work_func)
221218

lib/matplotlib/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,23 +1603,24 @@ def param(func):
16031603
else:
16041604
python_has_signature = True
16051605
else:
1606-
signature = inspect.signature
1607-
Parameter = inspect.Parameter
1606+
if python_has_signature:
1607+
signature = inspect.signature
1608+
Parameter = inspect.Parameter
16081609

16091610
if not python_has_signature:
16101611
arg_spec = inspect.getargspec(func)
16111612
_arg_names = arg_spec.args
1612-
_has_no_varargs = arg_spec.varargs is None
1613+
_has_varargs = arg_spec.varargs is not None
16131614
_has_varkwargs = arg_spec.keywords is not None
16141615
else:
16151616
sig = signature(func)
1616-
_has_no_varargs = True
1617+
_has_varargs = False
16171618
_has_varkwargs = False
16181619
_arg_names = []
16191620
params = list(sig.parameters.values())
16201621
for p in params:
16211622
if p.kind is Parameter.VAR_POSITIONAL:
1622-
_has_no_varargs = False
1623+
_has_varargs = True
16231624
elif p.kind is Parameter.VAR_KEYWORD:
16241625
_has_varkwargs = True
16251626
else:
@@ -1638,7 +1639,7 @@ def param(func):
16381639
# positional args can end up in **kwargs, so only *varargs make
16391640
# problems.
16401641
# http://stupidpythonideas.blogspot.de/2013/08/arguments-and-parameters.html
1641-
if _has_no_varargs:
1642+
if not _has_varargs:
16421643
# all args are "named", so no problem
16431644
# remove the first "ax" / self arg
16441645
arg_names = _arg_names[1:]

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5641,15 +5641,15 @@ def pcolorfast(self, *args, **kwargs):
56415641
self.autoscale_view(tight=True)
56425642
return ret
56435643

5644-
#@unpack_labeled_data() # takes 2d data :-(
5644+
@unpack_labeled_data()
56455645
def contour(self, *args, **kwargs):
56465646
if not self._hold:
56475647
self.cla()
56485648
kwargs['filled'] = False
56495649
return mcontour.QuadContourSet(self, *args, **kwargs)
56505650
contour.__doc__ = mcontour.QuadContourSet.contour_doc
56515651

5652-
#@unpack_labeled_data() # takes 2d data :-(
5652+
@unpack_labeled_data()
56535653
def contourf(self, *args, **kwargs):
56545654
if not self._hold:
56555655
self.cla()

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import matplotlib
1616

1717
from matplotlib import cbook
18-
from matplotlib.cbook import _string_to_bool, iterable, get_index_y, get_label
18+
from matplotlib.cbook import _string_to_bool, iterable, index_of, get_label
1919
from matplotlib import docstring
2020
import matplotlib.colors as mcolors
2121
import matplotlib.lines as mlines
@@ -31,7 +31,7 @@
3131
import matplotlib.image as mimage
3232
from matplotlib.offsetbox import OffsetBox
3333
from matplotlib.artist import allow_rasterization
34-
from matplotlib.cbook import iterable, get_index_y
34+
from matplotlib.cbook import iterable, index_of
3535
from matplotlib.rcsetup import cycler
3636

3737
rcParams = matplotlib.rcParams
@@ -356,7 +356,7 @@ def _plot_args(self, tup, kwargs):
356356
x = np.atleast_1d(tup[0])
357357
y = np.atleast_1d(tup[-1])
358358
else:
359-
x, y = get_index_y(tup[-1])
359+
x, y = index_of(tup[-1])
360360

361361
x, y = self._xy_from_xy(x, y)
362362

lib/matplotlib/cbook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ def pts_to_midstep(x, *args):
24912491
'step-mid': pts_to_midstep}
24922492

24932493

2494-
def get_index_y(y):
2494+
def index_of(y):
24952495
"""
24962496
A helper function to get the index of an input to plot
24972497
against if x values are not explicitly given.

0 commit comments

Comments
 (0)
0