Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7cf9cb7

Browse files
committed
Use super() in patch classes.
1 parent 3bd5cda commit 7cf9cb7

4 files changed

Lines changed: 36 additions & 42 deletions

File tree

lib/matplotlib/patches.py

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(self,
5656
5757
%(Patch)s
5858
"""
59-
artist.Artist.__init__(self)
59+
super().__init__()
6060

6161
if linewidth is None:
6262
linewidth = mpl.rcParams['patch.linewidth']
@@ -232,7 +232,7 @@ def contains_points(self, points, radius=None):
232232

233233
def update_from(self, other):
234234
# docstring inherited.
235-
artist.Artist.update_from(self, other)
235+
super().update_from(other)
236236
# For some properties we don't need or don't want to go through the
237237
# getters/setters, so we just copy them directly.
238238
self._edgecolor = other._edgecolor
@@ -644,7 +644,7 @@ def __init__(self, patch, ox, oy, props=None, **kwargs):
644644
645645
%(Patch)s
646646
"""
647-
Patch.__init__(self)
647+
super().__init__()
648648
self.patch = patch
649649
# Note: when removing props, we can directly pass kwargs to _update()
650650
# and remove self._props
@@ -683,7 +683,7 @@ def get_patch_transform(self):
683683

684684
def draw(self, renderer):
685685
self._update_transform(renderer)
686-
Patch.draw(self, renderer)
686+
super().draw(renderer)
687687

688688

689689
class Rectangle(Patch):
@@ -730,7 +730,7 @@ def __init__(self, xy, width, height, angle=0.0, **kwargs):
730730
%(Patch)s
731731
"""
732732

733-
Patch.__init__(self, **kwargs)
733+
super().__init__(**kwargs)
734734

735735
self._x0 = xy[0]
736736
self._y0 = xy[1]
@@ -910,7 +910,7 @@ def __init__(self, xy, numVertices, radius=5, orientation=0,
910910
self._poly_transform = transforms.Affine2D()
911911
self._update_transform()
912912

913-
Patch.__init__(self, **kwargs)
913+
super().__init__(**kwargs)
914914

915915
def _update_transform(self):
916916
self._poly_transform.clear() \
@@ -979,7 +979,7 @@ def __init__(self, path, **kwargs):
979979
980980
%(Patch)s
981981
"""
982-
Patch.__init__(self, **kwargs)
982+
super().__init__(**kwargs)
983983
self._path = path
984984

985985
def get_path(self):
@@ -1008,7 +1008,7 @@ def __init__(self, xy, closed=True, **kwargs):
10081008
10091009
%(Patch)s
10101010
"""
1011-
Patch.__init__(self, **kwargs)
1011+
super().__init__(**kwargs)
10121012
self._closed = closed
10131013
self.set_xy(xy)
10141014

@@ -1104,7 +1104,7 @@ def __init__(self, center, r, theta1, theta2, width=None, **kwargs):
11041104
11051105
%(Patch)s
11061106
"""
1107-
Patch.__init__(self, **kwargs)
1107+
super().__init__(**kwargs)
11081108
self.center = center
11091109
self.r, self.width = r, width
11101110
self.theta1, self.theta2 = theta1, theta2
@@ -1356,11 +1356,7 @@ def __init__(self, xy, radius=5,
13561356
13571357
%(Patch)s
13581358
"""
1359-
RegularPolygon.__init__(self, xy,
1360-
resolution,
1361-
radius,
1362-
orientation=0,
1363-
**kwargs)
1359+
super().__init__(xy, resolution, radius, orientation=0, **kwargs)
13641360

13651361

13661362
class Ellipse(Patch):
@@ -1392,7 +1388,7 @@ def __init__(self, xy, width, height, angle=0, **kwargs):
13921388
13931389
%(Patch)s
13941390
"""
1395-
Patch.__init__(self, **kwargs)
1391+
super().__init__(**kwargs)
13961392

13971393
self._center = xy
13981394
self._width, self._height = width, height
@@ -1518,7 +1514,7 @@ def __init__(self, xy, radius=5, **kwargs):
15181514
15191515
%(Patch)s
15201516
"""
1521-
Ellipse.__init__(self, xy, radius * 2, radius * 2, **kwargs)
1517+
super().__init__(xy, radius * 2, radius * 2, **kwargs)
15221518
self.radius = radius
15231519

15241520
def set_radius(self, radius):
@@ -1599,7 +1595,7 @@ def __init__(self, xy, width, height, angle=0.0,
15991595
if fill:
16001596
raise ValueError("Arc objects can not be filled")
16011597

1602-
Ellipse.__init__(self, xy, width, height, angle, **kwargs)
1598+
super().__init__(xy, width, height, angle, **kwargs)
16031599

16041600
self.theta1 = theta1
16051601
self.theta2 = theta2
@@ -3614,7 +3610,7 @@ def __init__(self, xy, width, height,
36143610
%(Patch)s
36153611
"""
36163612

3617-
Patch.__init__(self, **kwargs)
3613+
super().__init__(**kwargs)
36183614

36193615
self._x = xy[0]
36203616
self._y = xy[1]
@@ -3920,7 +3916,7 @@ def __init__(self, posA=None, posB=None, path=None,
39203916
kwargs.setdefault("joinstyle", "round")
39213917
kwargs.setdefault("capstyle", "round")
39223918

3923-
Patch.__init__(self, **kwargs)
3919+
super().__init__(**kwargs)
39243920

39253921
if posA is not None and posB is not None and path is None:
39263922
self._posA_posB = [posA, posB]
@@ -4271,18 +4267,15 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None,
42714267
self.axesA = axesA
42724268
self.axesB = axesB
42734269

4274-
FancyArrowPatch.__init__(self,
4275-
posA=(0, 0), posB=(1, 1),
4276-
arrowstyle=arrowstyle,
4277-
connectionstyle=connectionstyle,
4278-
patchA=patchA,
4279-
patchB=patchB,
4280-
shrinkA=shrinkA,
4281-
shrinkB=shrinkB,
4282-
mutation_scale=mutation_scale,
4283-
mutation_aspect=mutation_aspect,
4284-
clip_on=clip_on,
4285-
**kwargs)
4270+
super().__init__(posA=(0, 0), posB=(1, 1),
4271+
arrowstyle=arrowstyle,
4272+
connectionstyle=connectionstyle,
4273+
patchA=patchA, patchB=patchB,
4274+
shrinkA=shrinkA, shrinkB=shrinkB,
4275+
mutation_scale=mutation_scale,
4276+
mutation_aspect=mutation_aspect,
4277+
clip_on=clip_on,
4278+
**kwargs)
42864279
self._dpi_cor = dpi_cor
42874280

42884281
# if True, draw annotation only if self.xy is inside the axes
@@ -4411,4 +4404,4 @@ def draw(self, renderer):
44114404
self._renderer = renderer
44124405
if not self.get_visible() or not self._check_xy(renderer):
44134406
return
4414-
FancyArrowPatch.draw(self, renderer)
4407+
super().draw(renderer)

lib/matplotlib/table.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def __init__(self, xy, width, height,
8585
"""
8686

8787
# Call base
88-
Rectangle.__init__(self, xy, width=width, height=height, fill=fill,
89-
edgecolor=edgecolor, facecolor=facecolor)
88+
super().__init__(xy, width=width, height=height, fill=fill,
89+
edgecolor=edgecolor, facecolor=facecolor)
9090
self.set_clip_on(False)
9191
self.visible_edges = visible_edges
9292

@@ -99,12 +99,12 @@ def __init__(self, xy, width, height,
9999
horizontalalignment=loc, verticalalignment='center')
100100

101101
def set_transform(self, trans):
102-
Rectangle.set_transform(self, trans)
102+
super().set_transform(trans)
103103
# the text does not get the transform!
104104
self.stale = True
105105

106106
def set_figure(self, fig):
107-
Rectangle.set_figure(self, fig)
107+
super().set_figure(fig)
108108
self._text.set_figure(fig)
109109

110110
def get_text(self):
@@ -136,7 +136,7 @@ def draw(self, renderer):
136136
if not self.get_visible():
137137
return
138138
# draw the rectangle
139-
Rectangle.draw(self, renderer)
139+
super().draw(renderer)
140140
# position the text
141141
self._set_text_position(renderer)
142142
self._text.draw(renderer)

lib/mpl_toolkits/axes_grid1/inset_locator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def __init__(self, bbox, **kwargs):
154154
raise ValueError("transform should not be set")
155155

156156
kwargs["transform"] = IdentityTransform()
157-
Patch.__init__(self, **kwargs)
157+
super().__init__(**kwargs)
158158
self.bbox = bbox
159159

160160
def get_path(self):
@@ -277,10 +277,10 @@ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
277277

278278
kwargs["transform"] = IdentityTransform()
279279
if 'fill' in kwargs:
280-
Patch.__init__(self, **kwargs)
280+
super().__init__(**kwargs)
281281
else:
282282
fill = bool({'fc', 'facecolor', 'color'}.intersection(kwargs))
283-
Patch.__init__(self, fill=fill, **kwargs)
283+
super().__init__(fill=fill, **kwargs)
284284
self.bbox1 = bbox1
285285
self.bbox2 = bbox2
286286
self.loc1 = loc1
@@ -333,7 +333,7 @@ def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
333333
"""
334334
if "transform" in kwargs:
335335
raise ValueError("transform should not be set")
336-
BboxConnector.__init__(self, bbox1, bbox2, loc1a, loc2a, **kwargs)
336+
super().__init__(bbox1, bbox2, loc1a, loc2a, **kwargs)
337337
self.loc1b = loc1b
338338
self.loc2b = loc2b
339339

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class Patch3D(Patch):
296296
"""
297297

298298
def __init__(self, *args, zs=(), zdir='z', **kwargs):
299-
Patch.__init__(self, *args, **kwargs)
299+
super().__init__(*args, **kwargs)
300300
self.set_3d_properties(zs, zdir)
301301

302302
def set_3d_properties(self, verts, zs=0, zdir='z'):
@@ -327,6 +327,7 @@ class PathPatch3D(Patch3D):
327327
"""
328328

329329
def __init__(self, path, *, zs=(), zdir='z', **kwargs):
330+
# Not super().__init__!
330331
Patch.__init__(self, **kwargs)
331332
self.set_3d_properties(path, zs, zdir)
332333

0 commit comments

Comments
 (0)