8000 Use `super()` in hatch and path effects. · matplotlib/matplotlib@8f34a32 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f34a32

Browse files
committed
Use super() in hatch and path effects.
1 parent 7cf9cb7 commit 8f34a32

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/matplotlib/hatch.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,31 +130,34 @@ def __init__(self, hatch, density):
130130
path = Path.unit_circle()
131131
self.shape_vertices = path.vertices
132132
self.shape_codes = path.codes
133-
Shapes.__init__(self, hatch, density)
133+
super().__init__(hatch, density)
134134

135135

136136
class SmallCircles(Circles):
137137
size = 0.2
138138

139139
def __init__(self, hatch, density):
140140
self.num_rows = (hatch.count('o')) * density
141-
Circles.__init__(self, hatch, density)
141+
super().__init__(hatch, density)
142142

143143

144144
class LargeCircles(Circles):
145145
size = 0.35
146146

147147
def __init__(self, hatch, density):
148148
self.num_rows = (hatch.count('O')) * density
149-
Circles.__init__(self, hatch, density)
149+
super().__init__(hatch, density)
150150

151151

152+
# TODO: __init__ and class attributes override all attributes set by
153+
# SmallCircles. Should this class derive from Circles instead?
152154
class SmallFilledCircles(SmallCircles):
153155
size = 0.1
154156
filled = True
155157

156158
def __init__(self, hatch, density):
157159
self.num_rows = (hatch.count('.')) * density
160+
# Not super().__init__!
158161
Circles.__init__(self, hatch, density)
159162

160163

@@ -169,7 +172,7 @@ def __init__(self, hatch, density):
169172
self.shape_codes = np.full(len(self.shape_vertices), Path.LINETO,
170173
dtype=Path.code_type)
171174
self.shape_codes[0] = Path.MOVETO
172-
Shapes.__init__(self, hatch, density)
175+
super().__init__(hatch, density)
173176

174177
_hatch_types = [
175178
HorizontalHatch,

lib/matplotlib/patheffects.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ def draw_markers(
108108
if len(self._path_effects) == 1:
109109
# Call the base path effect function - this uses the unoptimised
110110
# approach of calling "draw_path" multiple times.
111-
return RendererBase.draw_markers(self, gc, marker_path,
112-
marker_trans, path, *args,
113-
**kwargs)
111+
return super().draw_markers(gc, marker_path, marker_trans, path,
112+
*args, **kwargs)
114113

115114
for path_effect in self._path_effects:
116115
renderer = self.copy_with_path_effect([path_effect])
@@ -127,9 +126,8 @@ def draw_path_collection(self, gc, master_transform, paths, *args,
127126
if len(self._path_effects) == 1:
128127
# Call the base path effect function - this uses the unoptimised
129128
# approach of calling "draw_path" multiple times.
130-
return RendererBase.draw_path_collection(self, gc,
131-
master_transform, paths,
132-
*args, **kwargs)
129+
return super().draw_path_collection(gc, master_transform, paths,
130+
*args, **kwargs)
133131

134132
for path_effect in self._path_effects:
135133
renderer = self.copy_with_path_effect([path_effect])

0 commit comments

Comments
 (0)
0