Skip to content

Deprecate unused parameters #16096

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 1 commit into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,12 @@ them.
``args_key`` and ``exec_key`` attributes of builtin `.MovieWriter`\s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These attributes are deprecated.

Unused parameters
~~~~~~~~~~~~~~~~~
The following parameters do not have any effect and are deprecated:

- arbitrary keyword arguments to ``StreamplotSet``
- parameter *quantize* of `.Path.cleaned()`
- parameter *s* of `.AnnotationBbox.get_fontsize()`
- parameter *label* of `.Tick`
2 changes: 1 addition & 1 deletion examples/specialty_plots/skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_view_interval(self):
# as well as create instances of the custom tick
class SkewXAxis(maxis.XAxis):
def _get_tick(self, major):
return SkewXTick(self.axes, None, '', major=major)
return SkewXTick(self.axes, None, major=major)

def get_view_interval(self):
return self.axes.upper_xlim[0], self.axes.lower_xlim[1]
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class Tick(martist.Artist):
The right/top tick label.

"""
def __init__(self, axes, loc, label,
@cbook._delete_parameter("3.3", "label")
def __init__(self, axes, loc, label=None,
Copy link
Contributor

Choose a reason for hiding this comment

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

it's a bit strange because the Tick now takes a bunch of kwargs which basically get forwarded to the label Text objects (labelsize, labelcolor, labelrotation) but can't set the text itself? (IOW should we make the label kwarg actually work instead?) Alternatively should these labelfoos also get deprecated?

Copy link
Member Author

@timhoffm timhoffm Jan 4, 2020

Choose a reason for hiding this comment

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

I don't know. The label text is not really in the control of the tick but in the control of the Locator/Formatter. All usages in our codebase just passed an empty string. So making label work seems not too desirable.

I think labelfoos are currently used for creating additional ticks with the right properties after set_tick_params() was used. Would have to check for that.

Generally, I'd rather make the Tick API smaller than larger because it's a bit performance critical; and we may want to migrate to somthing like a TickCollection at some point.

Copy link
Contributor

Choose a reason for hiding this comment

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

I strongly agree with making it smaller rather than larger, but would rather get rid of all label related args together if possible. Won't block over that though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can look into that, but would rather do in a separate PR. I have the itch that everything will break down if I remove the labelfoos. And sorting that out in a small clean PR is simpler. Also it's easier to revert if we find out this was a bad idea.

size=None, # points
width=None,
color=None,
Expand Down Expand Up @@ -1877,7 +1878,7 @@ def _get_tick(self, major):
tick_kw = self._major_tick_kw
else:
tick_kw = self._minor_tick_kw
return XTick(self.axes, 0, '', major=major, **tick_kw)
return XTick(self.axes, 0, major=major, **tick_kw)

def set_label_position(self, position):
"""
Expand Down Expand Up @@ -2173,7 +2174,7 @@ def _get_tick(self, major):
tick_kw = self._major_tick_kw
else:
tick_kw = self._minor_tick_kw
return YTick(self.axes, 0, '', major=major, **tick_kw)
return YTick(self.axes, 0, major=major, **tick_kw)

def set_label_position(self, position):
"""
Expand Down
24 changes: 21 additions & 3 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,13 @@ def set_message(self, s):
"""Display a message on toolbar or in status bar."""

def back(self, *args):
"""Move back up the view lim stack."""
"""
Move back up the view lim stack.

For convenience of being directly connected as a GUI callback, which
often get passed additional parameters, this method accepts arbitrary
parameters, but does not use them.
"""
self._nav_stack.back()
self.set_history_buttons()
self._update_view()
Expand All @@ -2708,13 +2714,25 @@ def remove_rubberband(self):
"""Remove the rubberband."""

def forward(self, *args):
"""Move forward in the view lim stack."""
"""
Move forward in the view lim stack.

For convenience of being directly connected as a GUI callback, which
often get passed additional parameters, this method accepts arbitrary
parameters, but does not use them.
"""
self._nav_stack.forward()
self.set_history_buttons()
self._update_view()

def home(self, *args):
"""Restore the original view."""
"""
Restore the original view.

For convenience of being directly connected as a GUI callback, which
often get passed additional parameters, this method accepts arbitrary
parameters, but does not use them.
"""
self._nav_stack.home()
self.set_history_buttons()
self._update_view()
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,7 @@ def set_fontsize(self, s=None):
self.prop = FontProperties(size=s)
self.stale = True

@cbook._delete_parameter("3.3", "s")
def get_fontsize(self, s=None):
"""
return fontsize in points
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ def iter_segments(self, transform=None, remove_nans=True, clip=None,
curr_vertices = np.append(curr_vertices, next(vertices))
yield curr_vertices, code

@cbook._delete_parameter("3.3", "quantize")
def cleaned(self, transform=None, remove_nans=False, clip=None,
quantize=False, simplify=False, curves=False,
stroke_width=1.0, snap=False, sketch=None):
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def _get_tick(self, major):
tick_kw = self._major_tick_kw
else:
tick_kw = self._minor_tick_kw
return ThetaTick(self.axes, 0, '', major=major, **tick_kw)
return ThetaTick(self.axes, 0, major=major, **tick_kw)

def _wrap_locator_formatter(self):
self.set_major_locator(ThetaLocator(self.get_major_locator()))
Expand Down Expand Up @@ -659,7 +659,7 @@ def _get_tick(self, major):
tick_kw = self._major_tick_kw
else:
tick_kw = self._minor_tick_kw
return RadialTick(self.axes, 0, '', major=major, **tick_kw)
return RadialTick(self.axes, 0, major=major, **tick_kw)

def _wrap_locator_formatter(self):
self.set_major_locator(RadialLocator(self.get_major_locator(),
Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/streamplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
class StreamplotSet:

def __init__(self, lines, arrows, **kwargs):
if kwargs:
cbook.warn_deprecated(
"3.3", "Passing arbitrary keyword arguments to StreamplotSet "
"is deprecated.")
self.lines = lines
self.arrows = arrows

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_skew.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_view_interval(self):
# as well as create instances of the custom tick
class SkewXAxis(maxis.XAxis):
def _get_tick(self, major):
return SkewXTick(self.axes, None, '', major=major)
return SkewXTick(self.axes, None, major=major)

def get_view_interval(self):
return self.axes.upper_xlim[0], self.axes.lower_xlim[1]
Expand Down