Skip to content

Commit f9f87d3

Browse files
committed
Expire FancyBboxPatch deprecations.
(Note that the 3.6 kwonlyification of mutation_scale is subsumed by the removal of bbox_transmuter.)
1 parent ccbd641 commit f9f87d3

File tree

2 files changed

+19
-46
lines changed

2 files changed

+19
-46
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Expiration of ``FancyBboxPatch`` deprecations
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
The `.FancyBboxPatch` constructor no longer accepts the *bbox_transmuter*
4+
parameter, nor can the *boxstyle* parameter be set to "custom" -- instead,
5+
directly set *boxstyle* to the relevant boxstyle instance. The
6+
*mutation_scale* and *mutation_aspect* parameters have also become
7+
keyword-only.
8+
9+
The *mutation_aspect* parameter is now handled internally and no longer passed
10+
to the boxstyle callables when mutating the patch path.

lib/matplotlib/patches.py

+9-46
Original file line numberDiff line numberDiff line change
@@ -3810,12 +3810,8 @@ def __str__(self):
38103810
return s % (self._x, self._y, self._width, self._height)
38113811

38123812
@_docstring.dedent_interpd
3813-
@_api.make_keyword_only("3.6", name="mutation_scale")
3814-
@_api.delete_parameter("3.4", "bbox_transmuter", alternative="boxstyle")
3815-
def __init__(self, xy, width, height,
3816-
boxstyle="round", bbox_transmuter=None,
3817-
mutation_scale=1, mutation_aspect=1,
3818-
**kwargs):
3813+
def __init__(self, xy, width, height, boxstyle="round", *,
3814+
mutation_scale=1, mutation_aspect=1, **kwargs):
38193815
"""
38203816
Parameters
38213817
----------
@@ -3857,27 +3853,12 @@ def __init__(self, xy, width, height,
38573853
"""
38583854

38593855
super().__init__(**kwargs)
3860-
3861-
self._x = xy[0]
3862-
self._y = xy[1]
3856+
self._x, self._y = xy
38633857
self._width = width
38643858
self._height = height
3865-
3866-
if boxstyle == "custom":
3867-
_api.warn_deprecated(
3868-
"3.4", message="Support for boxstyle='custom' is deprecated "
3869-
"since %(since)s and will be removed %(removal)s; directly "
3870-
"pass a boxstyle instance as the boxstyle parameter instead.")
3871-
if bbox_transmuter is None:
3872-
raise ValueError("bbox_transmuter argument is needed with "
3873-
"custom boxstyle")
3874-
self._bbox_transmuter = bbox_transmuter
3875-
else:
3876-
self.set_boxstyle(boxstyle)
3877-
3859+
self.set_boxstyle(boxstyle)
38783860
self._mutation_scale = mutation_scale
38793861
self._mutation_aspect = mutation_aspect
3880-
38813862
self.stale = True
38823863

38833864
@_docstring.dedent_interpd
@@ -3958,30 +3939,12 @@ def get_mutation_aspect(self):
39583939
def get_path(self):
39593940
"""Return the mutated path of the rectangle."""
39603941
boxstyle = self.get_boxstyle()
3961-
x = self._x
3962-
y = self._y
3963-
width = self._width
3964-
height = self._height
3965-
m_scale = self.get_mutation_scale()
39663942
m_aspect = self.get_mutation_aspect()
3967-
# Squeeze the given height by the aspect_ratio.
3968-
y, height = y / m_aspect, height / m_aspect
3969-
# Call boxstyle with squeezed height.
3970-
try:
3971-
inspect.signature(boxstyle).bind(x, y, width, height, m_scale)
3972-
except TypeError:
3973-
# Don't apply aspect twice.
3974-
path = boxstyle(x, y, width, height, m_scale, 1)
3975-
_api.warn_deprecated(
3976-
"3.4", message="boxstyles must be callable without the "
3977-
"'mutation_aspect' parameter since %(since)s; support for the "
3978-
"old call signature will be removed %(removal)s.")
3979-
else:
3980-
path = boxstyle(x, y, width, height, m_scale)
3981-
vertices, codes = path.vertices, path.codes
3982-
# Restore the height.
3983-
vertices[:, 1] = vertices[:, 1] * m_aspect
3984-
return Path(vertices, codes)
3943+
# Call boxstyle with y, height squeezed by aspect_ratio.
3944+
path = boxstyle(self._x, self._y / m_aspect,
3945+
self._width, self._height / m_aspect,
3946+
self.get_mutation_scale())
3947+
return Path(path.vertices * [1, m_aspect], path.codes) # Unsqueeze y.
39853948

39863949
# Following methods are borrowed from the Rectangle class.
39873950

0 commit comments

Comments
 (0)