Skip to content

Commit 866e03b

Browse files
committed
Expire BoxStyle._Base deprecation.
1 parent f278686 commit 866e03b

File tree

2 files changed

+19
-92
lines changed

2 files changed

+19
-92
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``BoxStyle._Base`` and ``transmute`` method of boxstyles
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... have been removed. Boxstyles implemented as classes no longer need to
4+
inherit from a base class.

lib/matplotlib/patches.py

+15-92
Original file line numberDiff line numberDiff line change
@@ -2268,94 +2268,19 @@ class BoxStyle(_Style):
22682268
22692269
%(AvailableBoxstyles)s
22702270
2271-
An instance of any boxstyle class is an callable object,
2272-
whose call signature is::
2271+
An instance of any boxstyle class is an callable object, whose call
2272+
signature is::
22732273
2274-
__call__(self, x0, y0, width, height, mutation_size)
2274+
__call__(self, x0, y0, width, height, mutation_size) -> Path
22752275
2276-
and returns a `.Path` instance. *x0*, *y0*, *width* and
2277-
*height* specify the location and size of the box to be
2278-
drawn. *mutation_scale* determines the overall size of the
2279-
mutation (by which I mean the transformation of the rectangle to
2280-
the fancy box).
2276+
*x0*, *y0*, *width* and *height* specify the location and size of the box
2277+
to be drawn; *mutation_size* scales the outline properties such as padding.
22812278
"""
22822279

22832280
_style_list = {}
22842281

2285-
@_api.deprecated("3.4")
2286-
class _Base:
2287-
"""
2288-
Abstract base class for styling of `.FancyBboxPatch`.
2289-
2290-
This class is not an artist itself. The `__call__` method returns the
2291-
`~matplotlib.path.Path` for outlining the fancy box. The actual drawing
2292-
is handled in `.FancyBboxPatch`.
2293-
2294-
Subclasses may only use parameters with default values in their
2295-
``__init__`` method because they must be able to be initialized
2296-
without arguments.
2297-
2298-
Subclasses must implement the `__call__` method. It receives the
2299-
enclosing rectangle *x0, y0, width, height* as well as the
2300-
*mutation_size*, which scales the outline properties such as padding.
2301-
It returns the outline of the fancy box as `.path.Path`.
2302-
"""
2303-
2304-
@_api.deprecated("3.4")
2305-
def transmute(self, x0, y0, width, height, mutation_size):
2306-
"""Return the `~.path.Path` outlining the given rectangle."""
2307-
return self(self, x0, y0, width, height, mutation_size, 1)
2308-
2309-
# This can go away once the deprecation period elapses, leaving _Base
2310-
# as a fully abstract base class just providing docstrings, no logic.
2311-
def __init_subclass__(cls):
2312-
transmute = _api.deprecate_method_override(
2313-
__class__.transmute, cls, since="3.4")
2314-
if transmute:
2315-
cls.__call__ = transmute
2316-
return
2317-
2318-
__call__ = cls.__call__
2319-
2320-
@_api.delete_parameter("3.4", "mutation_aspect")
2321-
def call_wrapper(
2322-
self, x0, y0, width, height, mutation_size,
2323-
mutation_aspect=_api.deprecation._deprecated_parameter):
2324-
if mutation_aspect is _api.deprecation._deprecated_parameter:
2325-
# Don't trigger deprecation warning internally.
2326-
return __call__(self, x0, y0, width, height, mutation_size)
2327-
else:
2328-
# Squeeze the given height by the aspect_ratio.
2329-
y0, height = y0 / mutation_aspect, height / mutation_aspect
2330-
path = self(x0, y0, width, height, mutation_size,
2331-
mutation_aspect)
2332-
vertices, codes = path.vertices, path.codes
2333-
# Restore the height.
2334-
vertices[:, 1] = vertices[:, 1] * mutation_aspect
2335-
return Path(vertices, codes)
2336-
2337-
cls.__call__ = call_wrapper
2338-
2339-
def __call__(self, x0, y0, width, height, mutation_size):
2340-
"""
2341-
Given the location and size of the box, return the path of
2342-
the box around it.
2343-
2344-
Parameters
2345-
----------
2346-
x0, y0, width, height : float
2347-
Location and size of the box.
2348-
mutation_size : float
2349-
A reference scale for the mutation.
2350-
2351-
Returns
2352-
-------
2353-
`~matplotlib.path.Path`
2354-
"""
2355-
raise NotImplementedError('Derived must override')
2356-
23572282
@_register_style(_style_list)
2358-
class Square(_Base):
2283+
class Square:
23592284
"""A square box."""
23602285

23612286
def __init__(self, pad=0.3):
@@ -2378,7 +2303,7 @@ def __call__(self, x0, y0, width, height, mutation_size):
23782303
closed=True)
23792304

23802305
@_register_style(_style_list)
2381-
class Circle(_Base):
2306+
class Circle:
23822307
"""A circular box."""
23832308

23842309
def __init__(self, pad=0.3):
@@ -2399,7 +2324,7 @@ def __call__(self, x0, y0, width, height, mutation_size):
23992324
max(width, height) / 2)
24002325

24012326
@_register_style(_style_list)
2402-
class LArrow(_Base):
2327+
class LArrow:
24032328
"""A box in the shape of a left-pointing arrow."""
24042329

24052330
def __init__(self, pad=0.3):
@@ -2441,7 +2366,7 @@ def __call__(self, x0, y0, width, height, mutation_size):
24412366
return p
24422367

24432368
@_register_style(_style_list)
2444-
class DArrow(_Base):
2369+
class DArrow:
24452370
"""A box in the shape of a two-way arrow."""
24462371
# Modified from LArrow to add a right arrow to the bbox.
24472372

@@ -2478,7 +2403,7 @@ def __call__(self, x0, y0, width, height, mutation_size):
24782403
closed=True)
24792404

24802405
@_register_style(_style_list)
2481-
class Round(_Base):
2406+
class Round:
24822407
"""A box with round corners."""
24832408

24842409
def __init__(self, pad=0.3, rounding_size=None):
@@ -2538,7 +2463,7 @@ def __call__(self, x0, y0, width, height, mutation_size):
25382463
return path
25392464

25402465
@_register_style(_style_list)
2541-
class Round4(_Base):
2466+
class Round4:
25422467
"""A box with rounded edges."""
25432468

25442469
def __init__(self, pad=0.3, rounding_size=None):
@@ -2589,7 +2514,7 @@ def __call__(self, x0, y0, width, height, mutation_size):
25892514
return path
25902515

25912516
@_register_style(_style_list)
2592-
class Sawtooth(_Base):
2517+
class Sawtooth:
25932518
"""A box with a sawtooth outline."""
25942519

25952520
def __init__(self, pad=0.3, tooth_size=None):
@@ -4025,11 +3950,9 @@ def set_boxstyle(self, boxstyle=None, **kwargs):
40253950
"""
40263951
if boxstyle is None:
40273952
return BoxStyle.pprint_styles()
4028-
4029-
if isinstance(boxstyle, BoxStyle._Base) or callable(boxstyle):
4030-
self._bbox_transmuter = boxstyle
4031-
else:
4032-
self._bbox_transmuter = BoxStyle(boxstyle, **kwargs)
3953+
self._bbox_transmuter = (
3954+
BoxStyle(boxstyle, **kwargs) if isinstance(boxstyle, str)
3955+
else boxstyle)
40333956
self.stale = True
40343957

40353958
def set_mutation_scale(self, scale):

0 commit comments

Comments
 (0)