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

Skip to content

Commit a8721cd

Browse files
committed
Move Transform.__repr__ = __str__ to base class.
1 parent fa69001 commit a8721cd

3 files changed

Lines changed: 3 additions & 48 deletions

File tree

lib/matplotlib/projections/geo.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ def __init__(self, resolution):
270270
def __str__(self):
271271
return "{}({})".format(type(self).__name__, self._resolution)
272272

273-
__repr__ = __str__
274-
275273
def transform_non_affine(self, ll):
276274
longitude = ll[:, 0:1]
277275
latitude = ll[:, 1:2]
@@ -315,8 +313,6 @@ def __init__(self, resolution):
315313
def __str__(self):
316314
return "{}({})".format(type(self).__name__, self._resolution)
317315

318-
__repr__ = __str__
319-
320316
def transform_non_affine(self, xy):
321317
# MGDTODO: Math is hard ;(
322318
return xy
@@ -359,8 +355,6 @@ def __init__(self, resolution):
359355
def __str__(self):
360356
return "{}({})".format(type(self).__name__, self._resolution)
361357

362-
__repr__ = __str__
363-
364358
def transform_non_affine(self, ll):
365359
longitude = ll[:, 0:1]
366360
latitude = ll[:, 1:2]
@@ -398,8 +392,6 @@ def __init__(self, resolution):
398392
def __str__(self):
399393
return "{}({})".format(type(self).__name__, self._resolution)
400394

401-
__repr__ = __str__
402-
403395
def transform_non_affine(self, xy):
404396
x, y = xy.T
405397
z = np.sqrt(1 - (x / 4) ** 2 - (y / 2) ** 2)
@@ -445,8 +437,6 @@ def __init__(self, resolution):
445437
def __str__(self):
446438
return "{}({})".format(type(self).__name__, self._resolution)
447439

448-
__repr__ = __str__
449-
450440
def transform_non_affine(self, ll):
451441
def d(theta):
452442
delta = -(theta + np.sin(theta) - pi_sin_l) / (1 + np.cos(theta))
@@ -503,8 +493,6 @@ def __init__(self, resolution):
503493
def __str__(self):
504494
return "{}({})".format(type(self).__name__, self._resolution)
505495

506-
__repr__ = __str__
507-
508496
def transform_non_affine(self, xy):
509497
x = xy[:, 0:1]
510498
y = xy[:, 1:2]
@@ -557,8 +545,6 @@ def __init__(self, center_longitude, center_latitude, resolution):
557545
def __str__(self):
558546
return "{}({})".format(type(self).__name__, self._resolution)
559547

560-
__repr__ = __str__
561-
562548
def transform_non_affine(self, ll):
563549
longitude = ll[:, 0:1]
564550
latitude = ll[:, 1:2]
@@ -609,8 +595,6 @@ def __init__(self, center_longitude, center_latitude, resolution):
609595
def __str__(self):
610596
return "{}({})".format(type(self).__name__, self._resolution)
611597

612-
__repr__ = __str__
613-
614598
def transform_non_affine(self, xy):
615599
x = xy[:, 0:1]
616600
y = xy[:, 1:2]

lib/matplotlib/projections/polar.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ def __str__(self):
4949
self._use_rmin,
5050
self._apply_theta_transforms))
5151

52-
__repr__ = __str__
53-
5452
def transform_non_affine(self, tr):
5553
xy = np.empty(tr.shape, float)
5654

@@ -115,8 +113,6 @@ def __str__(self):
115113
mtransforms._indent_str(self._scale_transform),
116114
mtransforms._indent_str(self._limits)))
117115

118-
__repr__ = __str__
119-
120116
def get_matrix(self):
121117
if self._invalid:
122118
limits_scaled = self._limits.transformed(self._scale_transform)
@@ -157,8 +153,6 @@ def __str__(self):
157153
self._use_rmin,
158154
self._apply_theta_transforms))
159155

160-
__repr__ = __str__
161-
162156
def transform_non_affine(self, xy):
163157
x = xy[:, 0:1]
164158
y = xy[:, 1:]
@@ -503,8 +497,6 @@ def __str__(self):
503497
mtransforms._indent_str(self.pad),
504498
mtransforms._indent_str(repr(self.mode))))
505499

506-
__repr__ = __str__
507-
508500
def get_matrix(self):
509501
if self._invalid:
510502
if self.mode == 'rlabel':
@@ -753,8 +745,6 @@ def __str__(self):
753745
mtransforms._indent_str(self._viewLim),
754746
mtransforms._indent_str(self._originLim)))
755747

756-
__repr__ = __str__
757-
758748
def get_points(self):
759749
if self._invalid:
760750
points = self._viewLim.get_points().copy()

lib/matplotlib/transforms.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,9 @@ def inverted(self):
16411641
"""
16421642
raise NotImplementedError()
16431643

1644+
def __repr__(self):
1645+
return str(self)
1646+
16441647

16451648
class TransformWrapper(Transform):
16461649
"""
@@ -1710,8 +1713,6 @@ def __str__(self):
17101713
.format(type(self).__name__,
17111714
_indent_str(self._child)))
17121715

1713-
__repr__ = __str__
1714-
17151716
def frozen(self):
17161717
return self._child.frozen()
17171718
frozen.__doc__ = Transform.frozen.__doc__
@@ -1943,8 +1944,6 @@ def __str__(self):
19431944
.format(type(self).__name__,
19441945
_indent_str(self._mtx)))
19451946

1946-
__repr__ = __str__
1947-
19481947
@staticmethod
19491948
def from_values(a, b, c, d, e, f):
19501949
"""
@@ -2151,8 +2150,6 @@ def __str__(self):
21512150
return ("{}()"
21522151
.format(type(self).__name__))
21532152

2154-
__repr__ = __str__
2155-
21562153
def get_matrix(self):
21572154
return self._mtx
21582155
get_matrix.__doc__ = Affine2DBase.get_matrix.__doc__
@@ -2258,8 +2255,6 @@ def __str__(self):
22582255
_indent_str(self._x),
22592256
_indent_str(self._y)))
22602257

2261-
__repr__ = __str__
2262-
22632258
def transform_non_affine(self, points):
22642259
if self._x.is_affine and self._y.is_affine:
22652260
return points
@@ -2370,8 +2365,6 @@ def __str__(self):
23702365
_indent_str(self._x),
23712366
_indent_str(self._y)))
23722367

2373-
__repr__ = __str__
2374-
23752368
def get_matrix(self):
23762369
if self._invalid:
23772370
if self._x == self._y:
@@ -2492,8 +2485,6 @@ def __str__(self):
24922485
_indent_str(self._a),
24932486
_indent_str(self._b)))
24942487

2495-
__repr__ = __str__
2496-
24972488
def transform_affine(self, points):
24982489
return self.get_affine().transform(points)
24992490
transform_affine.__doc__ = Transform.transform_affine.__doc__
@@ -2587,8 +2578,6 @@ def __str__(self):
25872578
_indent_str(self._a),
25882579
_indent_str(self._b)))
25892580

2590-
__repr__ = __str__
2591-
25922581
def get_matrix(self):
25932582
if self._invalid:
25942583
self._mtx = np.dot(
@@ -2658,8 +2647,6 @@ def __str__(self):
26582647
_indent_str(self._boxin),
26592648
_indent_str(self._boxout)))
26602649

2661-
__repr__ = __str__
2662-
26632650
def get_matrix(self):
26642651
if self._invalid:
26652652
inl, inb, inw, inh = self._boxin.bounds
@@ -2706,8 +2693,6 @@ def __str__(self):
27062693
.format(type(self).__name__,
27072694
_indent_str(self._boxout)))
27082695

2709-
__repr__ = __str__
2710-
27112696
def get_matrix(self):
27122697
if self._invalid:
27132698
outl, outb, outw, outh = self._boxout.bounds
@@ -2767,8 +2752,6 @@ def __str__(self):
27672752
.format(type(self).__name__,
27682753
_indent_str(self._boxin)))
27692754

2770-
__repr__ = __str__
2771-
27722755
def get_matrix(self):
27732756
if self._invalid:
27742757
inl, inb, inw, inh = self._boxin.bounds
@@ -2805,8 +2788,6 @@ def __str__(self):
28052788
.format(type(self).__name__,
28062789
_indent_str(self._t)))
28072790

2808-
__repr__ = __str__
2809-
28102791
def get_matrix(self):
28112792
if self._invalid:
28122793
xt, yt = self._scale_trans.transform_point(self._t)

0 commit comments

Comments
 (0)