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

Skip to content

Commit 6939574

Browse files
authored
Merge pull request #20436 from QuLogic/super-init
Add missing super __init__ in subclasses
2 parents e039d69 + 650160a commit 6939574

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

lib/matplotlib/colors.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,9 +1272,8 @@ def __init__(self, vcenter, vmin=None, vmax=None):
12721272
array([0., 0.25, 0.5, 0.625, 0.75, 0.875, 1.0])
12731273
"""
12741274

1275+
super().__init__(vmin=vmin, vmax=vmax)
12751276
self.vcenter = vcenter
1276-
self.vmin = vmin
1277-
self.vmax = vmax
12781277
if vcenter is not None and vmax is not None and vcenter >= vmax:
12791278
raise ValueError('vmin, vcenter, and vmax must be in '
12801279
'ascending order')
@@ -1353,12 +1352,10 @@ def __init__(self, vcenter=0, halfrange=None, clip=False):
13531352
>>> norm(data)
13541353
array([0.25, 0.5 , 1. ])
13551354
"""
1355+
super().__init__(vmin=None, vmax=None, clip=clip)
13561356
self._vcenter = vcenter
1357-
self.vmin = None
1358-
self.vmax = None
13591357
# calling the halfrange setter to set vmin and vmax
13601358
self.halfrange = halfrange
1361-
self.clip = clip
13621359

13631360
def _set_vmin_vmax(self):
13641361
"""
@@ -1696,9 +1693,7 @@ def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
16961693
"""
16971694
if clip and extend != 'neither':
16981695
raise ValueError("'clip=True' is not compatible with 'extend'")
1699-
self.clip = clip
1700-
self.vmin = boundaries[0]
1701-
self.vmax = boundaries[-1]
1696+
super().__init__(vmin=boundaries[0], vmax=boundaries[-1], clip=clip)
17021697
self.boundaries = np.asarray(boundaries)
17031698
self.N = len(self.boundaries)
17041699
if self.N < 2:

lib/matplotlib/dates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,9 +1668,9 @@ def __init__(self, interval=1, tz=None):
16681668
example, if ``interval=2``, mark every second microsecond.
16691669
16701670
"""
1671+
super().__init__(tz=tz)
16711672
self._interval = interval
16721673
self._wrapped_locator = ticker.MultipleLocator(interval)
1673-
self.tz = tz
16741674

16751675
def set_axis(self, axis):
16761676
self._wrapped_locator.set_axis(axis)

lib/matplotlib/mathtext.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class MathtextBackendPs(MathtextBackend):
189189
"_PSResult", "width height depth pswriter used_characters")
190190

191191
def __init__(self):
192+
super().__init__()
192193
self.pswriter = StringIO()
193194
self.lastfont = None
194195

@@ -230,6 +231,7 @@ class MathtextBackendPdf(MathtextBackend):
230231
"_PDFResult", "width height depth glyphs rects used_characters")
231232

232233
def __init__(self):
234+
super().__init__()
233235
self.glyphs = []
234236
self.rects = []
235237

@@ -260,6 +262,7 @@ class MathtextBackendSvg(MathtextBackend):
260262
backend.
261263
"""
262264
def __init__(self):
265+
super().__init__()
263266
self.svg_glyphs = []
264267
self.svg_rects = []
265268

@@ -293,6 +296,7 @@ class MathtextBackendPath(MathtextBackend):
293296
_Result = namedtuple("_Result", "width height depth glyphs rects")
294297

295298
def __init__(self):
299+
super().__init__()
296300
self.glyphs = []
297301
self.rects = []
298302

@@ -320,6 +324,7 @@ class MathtextBackendCairo(MathtextBackend):
320324
"""
321325

322326
def __init__(self):
327+
super().__init__()
323328
self.glyphs = []
324329
self.rects = []
325330

lib/matplotlib/textpath.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77

8-
from matplotlib import _text_helpers, dviread, font_manager, rcParams
8+
from matplotlib import _text_helpers, dviread, font_manager
99
from matplotlib.font_manager import FontProperties, get_font
1010
from matplotlib.ft2font import LOAD_NO_HINTING, LOAD_TARGET_LIGHT
1111
from matplotlib.mathtext import MathTextParser
@@ -385,11 +385,11 @@ def __init__(self, xy, s, size=None, prop=None,
385385

386386
self._cached_vertices = None
387387
s, ismath = Text(usetex=usetex)._preprocess_math(s)
388-
self._vertices, self._codes = text_to_path.get_text_path(
389-
prop, s, ismath=ismath)
388+
super().__init__(
389+
*text_to_path.get_text_path(prop, s, ismath=ismath),
390+
_interpolation_steps=_interpolation_steps,
391+
readonly=True)
390392
self._should_simplify = False
391-
self._simplify_threshold = rcParams['path.simplify_threshold']
392-
self._interpolation_steps = _interpolation_steps
393393

394394
def set_size(self, size):
395395
"""Set the text size."""
@@ -427,4 +427,5 @@ def _revalidate_path(self):
427427
.scale(self._size / text_to_path.FONT_SCALE)
428428
.translate(*self._xy))
429429
self._cached_vertices = tr.transform(self._vertices)
430+
self._cached_vertices.flags.writeable = False
430431
self._invalid = False

0 commit comments

Comments
 (0)