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

Skip to content

Commit f949caa

Browse files
authored
Merge pull request #13389 from anntzer/inherit-more-docstrings
Inherit more docstrings.
2 parents 136d986 + 816224f commit f949caa

File tree

10 files changed

+107
-154
lines changed

10 files changed

+107
-154
lines changed

examples/misc/custom_projection.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,18 +406,14 @@ def transform_non_affine(self, ll):
406406
x = (2 * sqrt2) * (cos_latitude * np.sin(half_long)) / alpha
407407
y = (sqrt2 * np.sin(latitude)) / alpha
408408
return np.column_stack([x, y])
409-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
410409

411410
def transform_path_non_affine(self, path):
412411
# vertices = path.vertices
413412
ipath = path.interpolated(self._resolution)
414413
return Path(self.transform(ipath.vertices), ipath.codes)
415-
transform_path_non_affine.__doc__ = \
416-
Transform.transform_path_non_affine.__doc__
417414

418415
def inverted(self):
419416
return HammerAxes.InvertedHammerTransform(self._resolution)
420-
inverted.__doc__ = Transform.inverted.__doc__
421417

422418
class InvertedHammerTransform(Transform):
423419
input_dims = 2
@@ -434,11 +430,9 @@ def transform_non_affine(self, xy):
434430
longitude = 2 * np.arctan((z * x) / (2 * (2 * z ** 2 - 1)))
435431
latitude = np.arcsin(y*z)
436432
return np.column_stack([longitude, latitude])
437-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
438433

439434
def inverted(self):
440435
return HammerAxes.HammerTransform(self._resolution)
441-
inverted.__doc__ = Transform.inverted.__doc__
442436

443437
def __init__(self, *args, **kwargs):
444438
self._longitude_cap = np.pi / 2.0

lib/matplotlib/axes/_axes.py

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4938,36 +4938,6 @@ def quiver(self, *args, **kw):
49384938
return q
49394939
quiver.__doc__ = mquiver.Quiver.quiver_doc
49404940

4941-
# args can by either Y or y1,y2,... and all should be replaced
4942-
@_preprocess_data()
4943-
def stackplot(self, x, *args, **kwargs):
4944-
return mstack.stackplot(self, x, *args, **kwargs)
4945-
stackplot.__doc__ = mstack.stackplot.__doc__
4946-
4947-
@_preprocess_data(replace_names=["x", "y", "u", "v", "start_points"])
4948-
def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
4949-
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
4950-
minlength=0.1, transform=None, zorder=None,
4951-
start_points=None, maxlength=4.0,
4952-
integration_direction='both'):
4953-
stream_container = mstream.streamplot(
4954-
self, x, y, u, v,
4955-
density=density,
4956-
linewidth=linewidth,
4957-
color=color,
4958-
cmap=cmap,
4959-
norm=norm,
4960-
arrowsize=arrowsize,
4961-
arrowstyle=arrowstyle,
4962-
minlength=minlength,
4963-
start_points=start_points,
4964-
transform=transform,
4965-
zorder=zorder,
4966-
maxlength=maxlength,
4967-
integration_direction=integration_direction)
4968-
return stream_container
4969-
streamplot.__doc__ = mstream.streamplot.__doc__
4970-
49714941
# args can be some combination of X, Y, U, V, C and all should be replaced
49724942
@_preprocess_data()
49734943
@docstring.dedent_interpd
@@ -6330,8 +6300,6 @@ def clabel(self, CS, *args, **kwargs):
63306300
return CS.clabel(*args, **kwargs)
63316301
clabel.__doc__ = mcontour.ContourSet.clabel.__doc__
63326302

6333-
table = mtable.table
6334-
63356303
#### Data analysis
63366304

63376305
@_preprocess_data(replace_names=["x", 'weights'], label_namer="x")
@@ -8125,18 +8093,17 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
81258093

81268094
return artists
81278095

8128-
def tricontour(self, *args, **kwargs):
8129-
return mtri.tricontour(self, *args, **kwargs)
8130-
tricontour.__doc__ = mtri.tricontour.__doc__
8096+
# Methods that are entirely implemented in other modules.
8097+
8098+
table = mtable.table
81318099

8132-
def tricontourf(self, *args, **kwargs):
8133-
return mtri.tricontourf(self, *args, **kwargs)
8134-
tricontourf.__doc__ = mtri.tricontour.__doc__
8100+
# args can by either Y or y1,y2,... and all should be replaced
8101+
stackplot = _preprocess_data()(mstack.stackplot)
81358102

8136-
def tripcolor(self, *args, **kwargs):
8137-
return mtri.tripcolor(self, *args, **kwargs)
8138-
tripcolor.__doc__ = mtri.tripcolor.__doc__
8103+
streamplot = _preprocess_data(
8104+
replace_names=["x", "y", "u", "v", "start_points"])(mstream.streamplot)
81398105

8140-
def triplot(self, *args, **kwargs):
8141-
return mtri.triplot(self, *args, **kwargs)
8142-
triplot.__doc__ = mtri.triplot.__doc__
8106+
tricontour = mtri.tricontour
8107+
tricontourf = mtri.tricontourf
8108+
tripcolor = mtri.tripcolor
8109+
triplot = mtri.triplot

lib/matplotlib/axis.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,11 @@ def get_children(self):
230230
return children
231231

232232
def set_clip_path(self, clippath, transform=None):
233+
# docstring inherited
233234
martist.Artist.set_clip_path(self, clippath, transform)
234235
self.gridline.set_clip_path(clippath, transform)
235236
self.stale = True
236237

237-
set_clip_path.__doc__ = martist.Artist.set_clip_path.__doc__
238-
239238
def get_pad_pixels(self):
240239
return self.figure.dpi * self._base_pad / 72
241240

lib/matplotlib/projections/geo.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,9 @@ def __str__(self):
256256
return "{}({})".format(type(self).__name__, self._resolution)
257257

258258
def transform_path_non_affine(self, path):
259+
# docstring inherited
259260
ipath = path.interpolated(self._resolution)
260261
return Path(self.transform(ipath.vertices), ipath.codes)
261-
transform_path_non_affine.__doc__ = \
262-
Transform.transform_path_non_affine.__doc__
263262

264263

265264
class AitoffAxes(GeoAxes):
@@ -269,6 +268,7 @@ class AitoffTransform(_GeoTransform):
269268
"""The base Aitoff transform."""
270269

271270
def transform_non_affine(self, ll):
271+
# docstring inherited
272272
longitude = ll[:, 0]
273273
latitude = ll[:, 1]
274274

@@ -286,22 +286,21 @@ def transform_non_affine(self, ll):
286286
xy[:, 0] = (cos_latitude * np.sin(half_long)) / sinc_alpha
287287
xy[:, 1] = np.sin(latitude) / sinc_alpha
288288
return xy
289-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
290289

291290
def inverted(self):
291+
# docstring inherited
292292
return AitoffAxes.InvertedAitoffTransform(self._resolution)
293-
inverted.__doc__ = Transform.inverted.__doc__
294293

295294
class InvertedAitoffTransform(_GeoTransform):
296295

297296
def transform_non_affine(self, xy):
297+
# docstring inherited
298298
# MGDTODO: Math is hard ;(
299299
return xy
300-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
301300

302301
def inverted(self):
302+
# docstring inherited
303303
return AitoffAxes.AitoffTransform(self._resolution)
304-
inverted.__doc__ = Transform.inverted.__doc__
305304

306305
def __init__(self, *args, **kwargs):
307306
self._longitude_cap = np.pi / 2.0
@@ -320,6 +319,7 @@ class HammerTransform(_GeoTransform):
320319
"""The base Hammer transform."""
321320

322321
def transform_non_affine(self, ll):
322+
# docstring inherited
323323
longitude = ll[:, 0:1]
324324
latitude = ll[:, 1:2]
325325

@@ -332,25 +332,24 @@ def transform_non_affine(self, ll):
332332
x = (2.0 * sqrt2) * (cos_latitude * np.sin(half_long)) / alpha
333333
y = (sqrt2 * np.sin(latitude)) / alpha
334334
return np.concatenate((x, y), 1)
335-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
336335

337336
def inverted(self):
337+
# docstring inherited
338338
return HammerAxes.InvertedHammerTransform(self._resolution)
339-
inverted.__doc__ = Transform.inverted.__doc__
340339

341340
class InvertedHammerTransform(_GeoTransform):
342341

343342
def transform_non_affine(self, xy):
343+
# docstring inherited
344344
x, y = xy.T
345345
z = np.sqrt(1 - (x / 4) ** 2 - (y / 2) ** 2)
346346
longitude = 2 * np.arctan((z * x) / (2 * (2 * z ** 2 - 1)))
347347
latitude = np.arcsin(y*z)
348348
return np.column_stack([longitude, latitude])
349-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
350349

351350
def inverted(self):
351+
# docstring inherited
352352
return HammerAxes.HammerTransform(self._resolution)
353-
inverted.__doc__ = Transform.inverted.__doc__
354353

355354
def __init__(self, *args, **kwargs):
356355
self._longitude_cap = np.pi / 2.0
@@ -369,6 +368,7 @@ class MollweideTransform(_GeoTransform):
369368
"""The base Mollweide transform."""
370369

371370
def transform_non_affine(self, ll):
371+
# docstring inherited
372372
def d(theta):
373373
delta = (-(theta + np.sin(theta) - pi_sin_l)
374374
/ (1 + np.cos(theta)))
@@ -401,15 +401,15 @@ def d(theta):
401401
xy[:, 1] = np.sqrt(2.0) * np.sin(aux)
402402

403403
return xy
404-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
405404

406405
def inverted(self):
406+
# docstring inherited
407407
return MollweideAxes.InvertedMollweideTransform(self._resolution)
408-
inverted.__doc__ = Transform.inverted.__doc__
409408

410409
class InvertedMollweideTransform(_GeoTransform):
411410

412411
def transform_non_affine(self, xy):
412+
# docstring inherited
413413
x = xy[:, 0:1]
414414
y = xy[:, 1:2]
415415

@@ -420,11 +420,10 @@ def transform_non_affine(self, xy):
420420
lat = np.arcsin((2 * theta + np.sin(2 * theta)) / np.pi)
421421

422422
return np.concatenate((lon, lat), 1)
423-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
424423

425424
def inverted(self):
425+
# docstring inherited
426426
return MollweideAxes.MollweideTransform(self._resolution)
427-
inverted.__doc__ = Transform.inverted.__doc__
428427

429428
def __init__(self, *args, **kwargs):
430429
self._longitude_cap = np.pi / 2.0
@@ -453,6 +452,7 @@ def __init__(self, center_longitude, center_latitude, resolution):
453452
self._center_latitude = center_latitude
454453

455454
def transform_non_affine(self, ll):
455+
# docstring inherited
456456
longitude = ll[:, 0:1]
457457
latitude = ll[:, 1:2]
458458
clong = self._center_longitude
@@ -470,14 +470,13 @@ def transform_non_affine(self, ll):
470470
y = k * (np.cos(clat)*sin_lat - np.sin(clat)*cos_lat*cos_diff_long)
471471

472472
return np.concatenate((x, y), 1)
473-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
474473

475474
def inverted(self):
475+
# docstring inherited
476476
return LambertAxes.InvertedLambertTransform(
477477
self._center_longitude,
478478
self._center_latitude,
479479
self._resolution)
480-
inverted.__doc__ = Transform.inverted.__doc__
481480

482481
class InvertedLambertTransform(_GeoTransform):
483482

@@ -487,6 +486,7 @@ def __init__(self, center_longitude, center_latitude, resolution):
487486
self._center_latitude = center_latitude
488487

489488
def transform_non_affine(self, xy):
489+
# docstring inherited
490490
x = xy[:, 0:1]
491491
y = xy[:, 1:2]
492492
clong = self._center_longitude
@@ -502,14 +502,13 @@ def transform_non_affine(self, xy):
502502
(x*sin_c) / (p*np.cos(clat)*cos_c - y*np.sin(clat)*sin_c))
503503

504504
return np.concatenate((lon, lat), 1)
505-
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__
506505

507506
def inverted(self):
507+
# docstring inherited
508508
return LambertAxes.LambertTransform(
509509
self._center_longitude,
510510
self._center_latitude,
511511
self._resolution)
512-
inverted.__doc__ = Transform.inverted.__doc__
513512

514513
def __init__(self, *args, center_longitude=0, center_latitude=0, **kwargs):
515514
self._longitude_cap = np.pi / 2

lib/matplotlib/projections/polar.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __str__(self):
4343
self._apply_theta_transforms))
4444

4545
def transform_non_affine(self, tr):
46+
# docstring inherited
4647
xy = np.empty(tr.shape, float)
4748

4849
t = tr[:, 0:1]
@@ -64,22 +65,19 @@ def transform_non_affine(self, tr):
6465
y[:] = np.where(mask, np.nan, r * np.sin(t))
6566

6667
return xy
67-
transform_non_affine.__doc__ = \
68-
mtransforms.Transform.transform_non_affine.__doc__
6968

7069
def transform_path_non_affine(self, path):
70+
# docstring inherited
7171
vertices = path.vertices
7272
if len(vertices) == 2 and vertices[0, 0] == vertices[1, 0]:
7373
return mpath.Path(self.transform(vertices), path.codes)
7474
ipath = path.interpolated(path._interpolation_steps)
7575
return mpath.Path(self.transform(ipath.vertices), ipath.codes)
76-
transform_path_non_affine.__doc__ = \
77-
mtransforms.Transform.transform_path_non_affine.__doc__
7876

7977
def inverted(self):
78+
# docstring inherited
8079
return PolarAxes.InvertedPolarTransform(self._axis, self._use_rmin,
8180
self._apply_theta_transforms)
82-
inverted.__doc__ = mtransforms.Transform.inverted.__doc__
8381

8482

8583
class PolarAffine(mtransforms.Affine2DBase):
@@ -108,6 +106,7 @@ def __str__(self):
108106
mtransforms._indent_str(self._limits)))
109107

110108
def get_matrix(self):
109+
# docstring inherited
111110
if self._invalid:
112111
limits_scaled = self._limits.transformed(self._scale_transform)
113112
yscale = limits_scaled.ymax - limits_scaled.ymin
@@ -118,7 +117,6 @@ def get_matrix(self):
118117
self._inverted = None
119118
self._invalid = 0
120119
return self._mtx
121-
get_matrix.__doc__ = mtransforms.Affine2DBase.get_matrix.__doc__
122120

123121

124122
class InvertedPolarTransform(mtransforms.Transform):
@@ -148,6 +146,7 @@ def __str__(self):
148146
self._apply_theta_transforms))
149147

150148
def transform_non_affine(self, xy):
149+
# docstring inherited
151150
x = xy[:, 0:1]
152151
y = xy[:, 1:]
153152
r = np.hypot(x, y)
@@ -165,13 +164,11 @@ def transform_non_affine(self, xy):
165164
r *= self._axis.get_rsign()
166165

167166
return np.concatenate((theta, r), 1)
168-
transform_non_affine.__doc__ = \
169-
mtransforms.Transform.transform_non_affine.__doc__
170167

171168
def inverted(self):
169+
# docstring inherited
172170
return PolarAxes.PolarTransform(self._axis, self._use_rmin,
173171
self._apply_theta_transforms)
174-
inverted.__doc__ = mtransforms.Transform.inverted.__doc__
175172

176173

177174
class ThetaFormatter(mticker.Formatter):
@@ -752,6 +749,7 @@ def __str__(self):
752749
mtransforms._indent_str(self._originLim)))
753750

754751
def get_points(self):
752+
# docstring inherited
755753
if self._invalid:
756754
points = self._viewLim.get_points().copy()
757755
# Scale angular limits to work with Wedge.
@@ -782,7 +780,6 @@ def get_points(self):
782780
self._invalid = 0
783781

784782
return self._points
785-
get_points.__doc__ = mtransforms.Bbox.get_points.__doc__
786783

787784

788785
class PolarAxes(Axes):
@@ -796,18 +793,14 @@ class PolarAxes(Axes):
796793
def __init__(self, *args,
797794
theta_offset=0, theta_direction=1, rlabel_position=22.5,
798795
**kwargs):
799-
"""
800-
Create a new Polar Axes for a polar plot.
801-
"""
796+
# docstring inherited
802797
self._default_theta_offset = theta_offset
803798
self._default_theta_direction = theta_direction
804799
self._default_rlabel_position = np.deg2rad(rlabel_position)
805-
806800
super().__init__(*args, **kwargs)
807801
self.use_sticky_edges = True
808802
self.set_aspect('equal', adjustable='box', anchor='C')
809803
self.cla()
810-
__init__.__doc__ = Axes.__init__.__doc__
811804

812805
def cla(self):
813806
Axes.cla(self)

0 commit comments

Comments
 (0)