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

Skip to content

Commit 3d20859

Browse files
committed
Use super() more in transforms.
1 parent 0414b3f commit 3d20859

File tree

5 files changed

+30
-31
lines changed

5 files changed

+30
-31
lines changed

lib/matplotlib/projections/geo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def __init__(self, resolution):
237237
Resolution is the number of steps to interpolate between each input
238238
line segment to approximate its path in curved space.
239239
"""
240-
Transform.__init__(self)
240+
super().__init__()
241241
self._resolution = resolution
242242

243243
def __str__(self):

lib/matplotlib/projections/polar.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class PolarTransform(mtransforms.Transform):
2525

2626
def __init__(self, axis=None, use_rmin=True,
2727
_apply_theta_transforms=True):
28-
mtransforms.Transform.__init__(self)
28+
super().__init__()
2929
self._axis = axis
3030
self._use_rmin = use_rmin
3131
self._apply_theta_transforms = _apply_theta_transforms
@@ -119,7 +119,7 @@ def __init__(self, scale_transform, limits):
119119
its bounds that is used is the y limits (for the radius limits).
120120
The theta range is handled by the non-affine transform.
121121
"""
122-
mtransforms.Affine2DBase.__init__(self)
122+
super().__init__()
123123
self._scale_transform = scale_transform
124124
self._limits = limits
125125
self.set_children(scale_transform, limits)
@@ -150,7 +150,7 @@ class InvertedPolarTransform(mtransforms.Transform):
150150

151151
def __init__(self, axis=None, use_rmin=True,
152152
_apply_theta_transforms=True):
153-
mtransforms.Transform.__init__(self)
153+
super().__init__()
154154
self._axis = axis
155155
self._use_rmin = use_rmin
156156
self._apply_theta_transforms = _apply_theta_transforms
@@ -478,8 +478,7 @@ class _ThetaShift(mtransforms.ScaledTranslation):
478478
of the axes, or using the rlabel position (``'rlabel'``).
479479
"""
480480
def __init__(self, axes, pad, mode):
481-
mtransforms.ScaledTranslation.__init__(self, pad, pad,
482-
axes.figure.dpi_scale_trans)
481+
super().__init__(pad, pad, axes.figure.dpi_scale_trans)
483482
self.set_children(axes._realViewLim)
484483
self.axes = axes
485484
self.mode = mode
@@ -509,7 +508,7 @@ def get_matrix(self):
509508
pady = np.sin(angle + np.pi / 2)
510509

511510
self._t = (self.pad * padx / 72, self.pad * pady / 72)
512-
return mtransforms.ScaledTranslation.get_matrix(self)
511+
return super().get_matrix()
513512

514513

515514
class RadialTick(maxis.YTick):
@@ -731,7 +730,7 @@ class _WedgeBbox(mtransforms.Bbox):
731730
Bbox determining the origin for the wedge, if different from *viewLim*
732731
"""
733732
def __init__(self, center, viewLim, originLim, **kwargs):
734-
mtransforms.Bbox.__init__(self, [[0, 0], [1, 1]], **kwargs)
733+
super().__init__([[0, 0], [1, 1]], **kwargs)
735734
self._center = center
736735
self._viewLim = viewLim
737736
self._originLim = originLim

lib/matplotlib/scale.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class LogTransform(Transform):
206206

207207
@cbook._rename_parameter("3.3", "nonpos", "nonpositive")
208208
def __init__(self, base, nonpositive='clip'):
209-
Transform.__init__(self)
209+
super().__init__()
210210
if base <= 0 or base == 1:
211211
raise ValueError('The log base cannot be <= 0 or == 1')
212212
self.base = base
@@ -247,7 +247,7 @@ class InvertedLogTransform(Transform):
247247
input_dims = output_dims = 1
248248

249249
def __init__(self, base):
250-
Transform.__init__(self)
250+
super().__init__()
251251
self.base = base
252252

253253
def __str__(self):
@@ -373,7 +373,7 @@ class SymmetricalLogTransform(Transform):
373373
input_dims = output_dims = 1
374374

375375
def __init__(self, base, linthresh, linscale):
376-
Transform.__init__(self)
376+
super().__init__()
377377
if base <= 1.0:
378378
raise ValueError("'base' must be larger than 1")
379379
if linthresh <= 0.0:
@@ -405,7 +405,7 @@ class InvertedSymmetricalLogTransform(Transform):
405405
input_dims = output_dims = 1
406406

407407
def __init__(self, base, linthresh, linscale):
408-
Transform.__init__(self)
408+
super().__init__()
409409
symlog = SymmetricalLogTransform(base, linthresh, linscale)
410410
self.base = base
411411
self.linthresh = linthresh
@@ -517,7 +517,7 @@ class LogitTransform(Transform):
517517

518518
@cbook._rename_parameter("3.3", "nonpos", "nonpositive")
519519
def __init__(self, nonpositive='mask'):
520-
Transform.__init__(self)
520+
super().__init__()
521521
cbook._check_in_list(['mask', 'clip'], nonpositive=nonpositive)
522522
self._nonpositive = nonpositive
523523
self._clip = {"clip": True, "mask": False}[nonpositive]
@@ -543,7 +543,7 @@ class LogisticTransform(Transform):
543543

544544
@cbook._rename_parameter("3.3", "nonpos", "nonpositive")
545545
def __init__(self, nonpositive='mask'):
546-
Transform.__init__(self)
546+
super().__init__()
547547
self._nonpositive = nonpositive
548548

549549
def transform_non_affine(self, a):

lib/matplotlib/tests/test_transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AssertingNonAffineTransform(mtransforms.Transform):
2222
is_affine = False
2323

2424
def __init__(self, *args, **kwargs):
25-
mtransforms.Transform.__init__(self, *args, **kwargs)
25+
super().__init__(*args, **kwargs)
2626
self.raise_on_transform = False
2727
self.underlying_transform = mtransforms.Affine2D().scale(10, 10)
2828

@@ -219,7 +219,7 @@ class NonAffineForTest(mtransforms.Transform):
219219

220220
def __init__(self, real_trans, *args, **kwargs):
221221
self.real_trans = real_trans
222-
mtransforms.Transform.__init__(self, *args, **kwargs)
222+
super().__init__(*args, **kwargs)
223223

224224
def transform_non_affine(self, values):
225225
return self.real_trans.transform(values)

lib/matplotlib/transforms.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ def __init__(self, points, **kwargs):
770770
points : ndarray
771771
A 2x2 numpy array of the form ``[[x0, y0], [x1, y1]]``.
772772
"""
773-
BboxBase.__init__(self, **kwargs)
773+
super().__init__(**kwargs)
774774
points = np.asarray(points, float)
775775
if points.shape != (2, 2):
776776
raise ValueError('Bbox points must be of the form '
@@ -791,7 +791,7 @@ def __init__(self, points, **kwargs):
791791

792792
def invalidate(self):
793793
self._check(self._points)
794-
TransformNode.invalidate(self)
794+
super().invalidate()
795795

796796
@staticmethod
797797
def unit():
@@ -1030,7 +1030,7 @@ def __init__(self, bbox, transform, **kwargs):
10301030
raise ValueError(
10311031
"The input and output dimensions of 'transform' must be 2")
10321032

1033-
BboxBase.__init__(self, **kwargs)
1033+
super().__init__(**kwargs)
10341034
self._bbox = bbox
10351035
self._transform = transform
10361036
self.set_children(bbox, transform)
@@ -1107,7 +1107,7 @@ def __init__(self, bbox, x0=None, y0=None, x1=None, y1=None, **kwargs):
11071107
if not bbox.is_bbox:
11081108
raise ValueError("'bbox' is not a bbox")
11091109

1110-
BboxBase.__init__(self, **kwargs)
1110+
super().__init__(**kwargs)
11111111
self._bbox = bbox
11121112
self.set_children(bbox)
11131113
self._points = None
@@ -1700,7 +1700,7 @@ class AffineBase(Transform):
17001700
is_affine = True
17011701

17021702
def __init__(self, *args, **kwargs):
1703-
Transform.__init__(self, *args, **kwargs)
1703+
super().__init__(*args, **kwargs)
17041704
self._inverted = None
17051705

17061706
def __array__(self, *args, **kwargs):
@@ -1839,7 +1839,7 @@ def __init__(self, matrix=None, **kwargs):
18391839
18401840
If *matrix* is None, initialize with the identity transform.
18411841
"""
1842-
Affine2DBase.__init__(self, **kwargs)
1842+
super().__init__(**kwargs)
18431843
if matrix is None:
18441844
# A bit faster than np.identity(3).
18451845
matrix = IdentityTransform._mtx.copy()
@@ -2288,7 +2288,7 @@ def __init__(self, a, b, **kwargs):
22882288
self.input_dims = a.input_dims
22892289
self.output_dims = b.output_dims
22902290

2291-
Transform.__init__(self, **kwargs)
2291+
super().__init__(**kwargs)
22922292
self._a = a
22932293
self._b = b
22942294
self.set_children(a, b)
@@ -2314,8 +2314,8 @@ def _invalidate_internal(self, value, invalidating_node):
23142314
(not self._a.is_affine or invalidating_node is self._a)):
23152315
value = Transform.INVALID
23162316

2317-
Transform._invalidate_internal(self, value=value,
2318-
invalidating_node=invalidating_node)
2317+
super()._invalidate_internal(value=value,
2318+
invalidating_node=invalidating_node)
23192319

23202320
def __eq__(self, other):
23212321
if isinstance(other, (CompositeGenericTransform, CompositeAffine2D)):
@@ -2401,7 +2401,7 @@ def __init__(self, a, b, **kwargs):
24012401
self.input_dims = a.input_dims
24022402
self.output_dims = b.output_dims
24032403

2404-
Affine2DBase.__init__(self, **kwargs)
2404+
super().__init__(**kwargs)
24052405
self._a = a
24062406
self._b = b
24072407
self.set_children(a, b)
@@ -2472,7 +2472,7 @@ def __init__(self, boxin, boxout, **kwargs):
24722472
if not boxin.is_bbox or not boxout.is_bbox:
24732473
raise ValueError("'boxin' and 'boxout' must be bbox")
24742474

2475-
Affine2DBase.__init__(self, **kwargs)
2475+
super().__init__(**kwargs)
24762476
self._boxin = boxin
24772477
self._boxout = boxout
24782478
self.set_children(boxin, boxout)
@@ -2516,7 +2516,7 @@ def __init__(self, boxout, **kwargs):
25162516
if not boxout.is_bbox:
25172517
raise ValueError("'boxout' must be bbox")
25182518

2519-
Affine2DBase.__init__(self, **kwargs)
2519+
super().__init__(**kwargs)
25202520
self._boxout = boxout
25212521
self.set_children(boxout)
25222522
self._mtx = None
@@ -2570,7 +2570,7 @@ def __init__(self, boxin, **kwargs):
25702570
if not boxin.is_bbox:
25712571
raise ValueError("'boxin' must be bbox")
25722572

2573-
Affine2DBase.__init__(self, **kwargs)
2573+
super().__init__(**kwargs)
25742574
self._boxin = boxin
25752575
self.set_children(boxin)
25762576
self._mtx = None
@@ -2601,7 +2601,7 @@ class ScaledTranslation(Affine2DBase):
26012601
have been transformed by *scale_trans*.
26022602
"""
26032603
def __init__(self, xt, yt, scale_trans, **kwargs):
2604-
Affine2DBase.__init__(self, **kwargs)
2604+
super().__init__(**kwargs)
26052605
self._t = (xt, yt)
26062606
self._scale_trans = scale_trans
26072607
self.set_children(scale_trans)
@@ -2671,7 +2671,7 @@ def __init__(self, path, transform):
26712671
transform : `Transform`
26722672
"""
26732673
cbook._check_isinstance(Transform, transform=transform)
2674-
TransformNode.__init__(self)
2674+
super().__init__()
26752675
self._path = path
26762676
self._transform = transform
26772677
self.set_children(transform)

0 commit comments

Comments
 (0)