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

Skip to content

Commit 6eca9c5

Browse files
committed
Fix broken references.
In particular, the property table for artists was changed to point links to the parent method which actually provides the docstring, if the docstring is inherited.
1 parent bed7da0 commit 6eca9c5

File tree

7 files changed

+63
-78
lines changed

7 files changed

+63
-78
lines changed

doc/api/axis_api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Interactive
146146
:template: autosummary.rst
147147
:nosignatures:
148148

149-
149+
Axis.contains
150150
Axis.get_pickradius
151151
Axis.set_pickradius
152152

doc/missing-references.json

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@
175175
"doc/api/prev_api_changes/api_changes_2.2.0.rst:215"
176176
],
177177
"Patch3DCollection": [
178-
"doc/api/toolkits/mplot3d.rst:92:<autosummary>:1"
178+
"doc/api/toolkits/mplot3d.rst:83:<autosummary>:1"
179179
],
180180
"Path3DCollection": [
181-
"doc/api/toolkits/mplot3d.rst:92:<autosummary>:1"
181+
"doc/api/toolkits/mplot3d.rst:83:<autosummary>:1"
182182
],
183183
"_FancyAxislineStyle.FilledArrow": [
184184
"<unknown>:1"
@@ -207,15 +207,15 @@
207207
],
208208
"matplotlib.axes._axes.Axes": [
209209
"doc/api/artist_api.rst:189",
210-
"doc/api/axes_api.rst:686",
210+
"doc/api/axes_api.rst:613",
211211
"lib/matplotlib/projections/polar.py:docstring of matplotlib.projections.polar.PolarAxes:1",
212212
"lib/mpl_toolkits/axes_grid1/mpl_axes.py:docstring of mpl_toolkits.axes_grid1.mpl_axes.Axes:1",
213213
"lib/mpl_toolkits/axisartist/axislines.py:docstring of mpl_toolkits.axisartist.axislines.Axes:1",
214214
"lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D:1"
215215
],
216216
"matplotlib.axes._base._AxesBase": [
217217
"doc/api/artist_api.rst:189",
218-
"doc/api/axes_api.rst:686",
218+
"doc/api/axes_api.rst:613",
219219
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes:1"
220220
],
221221
"matplotlib.backend_bases.FigureCanvas": [
@@ -380,8 +380,6 @@
380380
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Fixed:1",
381381
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Fraction:1",
382382
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.MaxExtent:1",
383-
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.MaxHeight:1",
384-
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.MaxWidth:1",
385383
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Padded:1",
386384
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.Scaled:1",
387385
"lib/mpl_toolkits/axes_grid1/axes_size.py:docstring of mpl_toolkits.axes_grid1.axes_size.SizeFromFunc:1"
@@ -593,7 +591,7 @@
593591
"doc/devel/contributing.rst:546"
594592
],
595593
"Artist.sticky_edges": [
596-
"doc/api/axes_api.rst:357:<autosummary>:1",
594+
"doc/api/axes_api.rst:362:<autosummary>:1",
597595
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.use_sticky_edges:2"
598596
],
599597
"ArtistInspector.aliasd": [
@@ -612,12 +610,12 @@
612610
"doc/users/prev_whats_new/whats_new_3.1.0.rst:247"
613611
],
614612
"Axes.dataLim": [
615-
"doc/api/axes_api.rst:297:<autosummary>:1",
613+
"doc/api/axes_api.rst:302:<autosummary>:1",
616614
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes.Axes.update_datalim:2",
617615
"lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D.update_datalim:2"
618616
],
619617
"Axes.datalim": [
620-
"doc/api/axes_api.rst:297:<autosummary>:1",
618+
"doc/api/axes_api.rst:302:<autosummary>:1",
621619
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes.Axes.update_datalim_bounds:2"
622620
],
623621
"Axes.fmt_xdata": [
@@ -635,7 +633,7 @@
635633
"doc/api/prev_api_changes/api_changes_3.2.0/behavior.rst:96"
636634
],
637635
"AxesBase": [
638-
"doc/api/axes_api.rst:449:<autosummary>:1",
636+
"doc/api/axes_api.rst:454:<autosummary>:1",
639637
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes.Axes.add_child_axes:2"
640638
],
641639
"Axis._update_ticks": [
@@ -663,10 +661,6 @@
663661
"doc/devel/MEP/MEP22.rst:60",
664662
"doc/devel/MEP/MEP23.rst:70"
665663
],
666-
"ClabelText": [
667-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.clabel:68",
668-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.clabel:68"
669-
],
670664
"ConnectionPatch": [
671665
"doc/users/prev_whats_new/whats_new_3.1.0.rst:178"
672666
],
@@ -741,10 +735,10 @@
741735
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.hexbin:71"
742736
],
743737
"QuadContourSet.changed()": [
744-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.contour:130",
745-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.contourf:130",
746-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contour:130",
747-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contourf:130"
738+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.contour:132",
739+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.contourf:132",
740+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contour:132",
741+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contourf:132"
748742
],
749743
"Quit": [
750744
"doc/devel/MEP/MEP22.rst:78"
@@ -829,6 +823,9 @@
829823
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.indicate_inset:19",
830824
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.inset_axes:11"
831825
],
826+
"axes": [
827+
"lib/matplotlib/axis.py:docstring of matplotlib.axis.Axis:23"
828+
],
832829
"axes.Axes.patch": [
833830
"doc/api/prev_api_changes/api_changes_1.3.x.rst:36"
834831
],
@@ -979,6 +976,7 @@
979976
"doc/devel/MEP/MEP23.rst:68"
980977
],
981978
"get_contains": [
979+
"lib/matplotlib/artist.py:docstring of matplotlib.axis.Axis.contains:29",
982980
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend.contains:29",
983981
"lib/matplotlib/offsetbox.py:docstring of matplotlib.offsetbox.AnnotationBbox.contains:29",
984982
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.QuiverKey.contains:29",
@@ -1003,15 +1001,8 @@
10031001
"h_pad": [
10041002
"lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure.set_constrained_layout:5"
10051003
],
1006-
"handler_map": [
1007-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.legend:242",
1008-
"lib/matplotlib/figure.py:docstring of matplotlib.figure.Figure.legend:206",
1009-
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend:201",
1010-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.figlegend:206",
1011-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.legend:242"
1012-
],
10131004
"image": [
1014-
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:72"
1005+
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:73"
10151006
],
10161007
"images": [
10171008
"lib/matplotlib/image.py:docstring of matplotlib.image.composite_images:2"
@@ -1504,10 +1495,11 @@
15041495
"doc/users/prev_whats_new/whats_new_3.1.0.rst:135"
15051496
],
15061497
"plot": [
1498+
"doc/tutorials/introductory/customizing.rst:193",
15071499
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:4"
15081500
],
15091501
"plot_include_source": [
1510-
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:51"
1502+
"lib/matplotlib/sphinxext/plot_directive.py:docstring of matplotlib.sphinxext.plot_directive:52"
15111503
],
15121504
"print_xyz": [
15131505
"lib/matplotlib/backends/backend_template.py:docstring of matplotlib.backends.backend_template:22"
@@ -1538,6 +1530,7 @@
15381530
"doc/devel/MEP/MEP23.rst:66"
15391531
],
15401532
"set_contains": [
1533+
"lib/matplotlib/artist.py:docstring of matplotlib.axis.Axis.contains:29",
15411534
"lib/matplotlib/legend.py:docstring of matplotlib.legend.Legend.contains:29",
15421535
"lib/matplotlib/offsetbox.py:docstring of matplotlib.offsetbox.AnnotationBbox.contains:29",
15431536
"lib/matplotlib/quiver.py:docstring of matplotlib.quiver.QuiverKey.contains:29",

doc/users/prev_whats_new/whats_new_1.5.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,12 @@ which allow artist-level control of LaTeX rendering vs. the internal mathtex
509509
rendering.
510510

511511

512-
`.Axes.remove()` works as expected
513-
``````````````````````````````````
512+
``Axes.remove()`` works as expected
513+
```````````````````````````````````
514514

515515
As with artists added to an :class:`~matplotlib.axes.Axes`,
516516
`~.axes.Axes` objects can be removed from their figure via
517-
:meth:`~matplotlib.axes.Axes.remove()`.
517+
`~.Artist.remove()`.
518518

519519

520520
API Consistency fix within Locators set_params() function

examples/pyplots/align_ylabels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def make_plot(axs):
5555
#
5656
#
5757
# Or we can manually align the axis labels between subplots manually using the
58-
# `~.YAxis.set_label_coords` method of the y-axis object. Note this requires
58+
# `~.Axis.set_label_coords` method of the y-axis object. Note this requires
5959
# we know a good offset value which is hardcoded.
6060

6161
fig, axs = plt.subplots(2, 2)

lib/matplotlib/artist.py

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ def _default_contains(self, mouseevent, figure=None):
396396
return inside, info
397397
# subclass-specific implementation follows
398398
399-
The *figure* kwarg is provided for the implementation of
400-
`Figure.contains`.
399+
The *canvas* kwarg is provided for the implementation of
400+
`.Figure.contains`.
401401
"""
402402
if callable(self._contains):
403403
return self._contains(self, mouseevent)
@@ -1297,24 +1297,6 @@ def get_valid_values(self, attr):
12971297

12981298
return 'unknown'
12991299

1300-
def _get_setters_and_targets(self):
1301-
"""
1302-
Get the attribute strings and a full path to where the setter
1303-
is defined for all setters in an object.
1304-
"""
1305-
setters = []
1306-
for name in dir(self.o):
1307-
if not name.startswith('set_'):
1308-
continue
1309-
func = getattr(self.o, name)
1310-
if (not callable(func)
1311-
or len(inspect.signature(func).parameters) < 2
1312-
or self.is_alias(func)):
1313-
continue
1314-
setters.append(
1315-
(name[4:], f"{func.__module__}.{func.__qualname__}"))
1316-
return setters
1317-
13181300
def _replace_path(self, source_class):
13191301
"""
13201302
Changes the full path to the public API path that is used
@@ -1331,7 +1313,17 @@ def get_setters(self):
13311313
Get the attribute strings with setters for object. e.g., for a line,
13321314
return ``['markerfacecolor', 'linewidth', ....]``.
13331315
"""
1334-
return [prop for prop, target in self._get_setters_and_targets()]
1316+
setters = []
1317+
for name in dir(self.o):
1318+
if not name.startswith('set_'):
1319+
continue
1320+
func = getattr(self.o, name)
1321+
if (not callable(func)
1322+
or len(inspect.signature(func).parameters) < 2
1323+
or self.is_alias(func)):
1324+
continue
1325+
setters.append(name[4:])
1326+
return setters
13351327

13361328
def is_alias(self, o):
13371329
"""Return whether method object *o* is an alias for another method."""
@@ -1380,24 +1372,20 @@ def pprint_setters(self, prop=None, leadingspace=2):
13801372
accepts = self.get_valid_values(prop)
13811373
return '%s%s: %s' % (pad, prop, accepts)
13821374

1383-
attrs = self._get_setters_and_targets()
1384-
attrs.sort()
13851375
lines = []
1386-
1387-
for prop, path in attrs:
1376+
for prop in sorted(self.get_setters()):
13881377
accepts = self.get_valid_values(prop)
13891378
name = self.aliased_name(prop)
1390-
13911379
lines.append('%s%s: %s' % (pad, name, accepts))
13921380
return lines
13931381

13941382
def pprint_setters_rest(self, prop=None, leadingspace=4):
13951383
"""
1396-
If *prop* is *None*, return a list of strings of all settable
1397-
properties and their valid values. Format the output for ReST
1384+
If *prop* is *None*, return a list of ReST-formatted strings of all
1385+
settable properties and their valid values.
13981386
13991387
If *prop* is not *None*, it is a valid property name and that
1400-
property will be returned as a string of property : valid
1388+
property will be returned as a string of "property : valid"
14011389
values.
14021390
"""
14031391
if leadingspace:
@@ -1408,13 +1396,24 @@ def pprint_setters_rest(self, prop=None, leadingspace=4):
14081396
accepts = self.get_valid_values(prop)
14091397
return '%s%s: %s' % (pad, prop, accepts)
14101398

1411-
attrs = sorted(self._get_setters_and_targets())
1412-
1413-
names = [self.aliased_name_rest(prop, target).replace(
1414-
'_base._AxesBase', 'Axes').replace(
1415-
'_axes.Axes', 'Axes')
1416-
for prop, target in attrs]
1417-
accepts = [self.get_valid_values(prop) for prop, target in attrs]
1399+
prop_and_qualnames = []
1400+
for prop in sorted(self.get_setters()):
1401+
# Find the parent method which actually provides the docstring.
1402+
for cls in self.o.__mro__:
1403+
method = getattr(cls, f"set_{prop}", None)
1404+
if method and method.__doc__ is not None:
1405+
break
1406+
else: # No docstring available.
1407+
method = getattr(self.o, f"set_{prop}")
1408+
prop_and_qualnames.append(
1409+
(prop, f"{method.__module__}.{method.__qualname__}"))
1410+
1411+
names = [self.aliased_name_rest(prop, target)
1412+
.replace('_base._AxesBase', 'Axes')
1413+
.replace('_axes.Axes', 'Axes')
1414+
for prop, target in prop_and_qualnames]
1415+
accepts = [self.get_valid_values(prop)
1416+
for prop, _ in prop_and_qualnames]
14181417

14191418
col0_len = max(len(n) for n in names)
14201419
col1_len = max(len(a) for a in accepts)

lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,7 @@ def _init_axis(self):
570570
self._update_transScale()
571571

572572
def set_figure(self, fig):
573-
"""
574-
Set the `.Figure` for this `.Axes`.
575-
576-
Parameters
577-
----------
578-
fig : `.Figure`
579-
"""
573+
# docstring inherited
580574
martist.Artist.set_figure(self, fig)
581575

582576
self.bbox = mtransforms.TransformedBbox(self._position,
@@ -2831,7 +2825,7 @@ def grid(self, b=None, which='major', axis='both', **kwargs):
28312825
grid is determined by the zorder of each axis, not by the zorder of the
28322826
`.Line2D` objects comprising the grid. Therefore, to set grid zorder,
28332827
use `.set_axisbelow` or, for more control, call the
2834-
`~matplotlib.axis.Axis.set_zorder` method of each axis.
2828+
`~.Artist.set_zorder` method of each axis.
28352829
"""
28362830
if len(kwargs):
28372831
b = True

tutorials/introductory/lifecycle.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@
157157

158158
###############################################################################
159159
# Next, we'll add labels to the plot. To do this with the OO interface,
160-
# we can use the :meth:`axes.Axes.set` method to set properties of this
161-
# Axes object.
160+
# we can use the `.Artist.set` method to set properties of this Axes object.
162161

163162
fig, ax = plt.subplots()
164163
ax.barh(group_names, group_data)

0 commit comments

Comments
 (0)