8000 Soft-deprecate mutation_aspect=None. · matplotlib/matplotlib@da57be3 · GitHub
[go: up one dir, main page]

Skip to content

Commit da57be3

Browse files
committed
Soft-deprecate mutation_aspect=None.
mutation_aspect=1 is a synonym that's just simpler and consistent with other scalar values. Not really worth a proper deprecation; just changing the defaults in the signatures and normalizing None to 1 in the getter.
1 parent 0cf3974 commit da57be3

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

lib/matplotlib/patches.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,11 +2892,11 @@ def __call__(self, path, mutation_size, linewidth,
28922892
path_shrunk = Path(vertices, path.codes)
28932893
# call transmute method with squeezed height.
28942894
path_mutated, fillable = self.transmute(path_shrunk,
2895-
linewidth,
2896-
mutation_size)
2895+
mutation_size,
2896+
linewidth)
28972897
if np.iterable(fillable):
28982898
path_list = []
2899-
for p in zip(path_mutated):
2899+
for p in path_mutated:
29002900
# Restore the height
29012901
path_list.append(
29022902
Path(p.vertices * [1, aspect_ratio], p.codes))
@@ -3565,10 +3565,8 @@ def __str__(self):
35653565

35663566
@docstring.dedent_interpd
35673567
def __init__(self, xy, width, height,
3568-
boxstyle="round",
3569-
bbox_transmuter=None,
3570-
mutation_scale=1.,
3571-
mutation_aspect=None,
3568+
boxstyle="round", bbox_transmuter=None,
3569+
mutation_scale=1, mutation_aspect=1,
35723570
**kwargs):
35733571
"""
35743572
Parameters
@@ -3597,7 +3595,7 @@ def __init__(self, xy, width, height,
35973595
Scaling factor applied to the attributes of the box style
35983596
(e.g. pad or rounding_size).
35993597
3600-
mutation_aspect : float, optional
3598+
mutation_aspect : float, default: 1
36013599
The height of the rectangle will be squeezed by this value before
36023600
the mutation and the mutated box will be stretched by the inverse
36033601
of it. For example, this allows different horizontal and vertical
@@ -3703,7 +3701,8 @@ def set_mutation_aspect(self, aspect):
37033701

37043702
def get_mutation_aspect(self):
37053703
"""Return the aspect ratio of the bbox mutation."""
3706-
return self._mutation_aspect
3704+
return (self._mutation_aspect if self._mutation_aspect is not None
3705+
else 1) # backcompat.
37073706

37083707
def get_boxstyle(self):
37093708
"""Return the boxstyle object."""
@@ -3829,16 +3828,11 @@ def __str__(self):
38293828
return f"{type(self).__name__}({self._path_original})"
38303829

38313830
@docstring.dedent_interpd
3832-
def __init__(self, posA=None, posB=None,
3833-
path=None,
3834-
arrowstyle="simple",
3835-
connectionstyle="arc3",
3836-
patchA=None,
3837-
patchB=None,
3838-
shrinkA=2,
3839-
shrinkB=2,
3840-
mutation_scale=1,
3841-
mutation_aspect=None,
3831+
def __init__(self, posA=None, posB=None, path=None,
3832+
arrowstyle="simple", connectionstyle="arc3",
3833+
patchA=None, patchB=None,
3834+
shrinkA=2, shrinkB=2,
3835+
mutation_scale=1, mutation_aspect=1,
38423836
dpi_cor=1,
38433837
**kwargs):
38443838
"""
@@ -4103,7 +4097,8 @@ def set_mutation_aspect(self, aspect):
41034097

41044098
def get_mutation_aspect(self):
41054099
"""Return the aspect ratio of the bbox mutation."""
4106-
return self._mutation_aspect
4100+
return (self._mutation_aspect if self._mutation_aspect is not None
4101+
else 1) # backcompat.
41074102

41084103
def get_path(self):
41094104
"""

0 commit comments

Comments
 (0)
0