Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Generalize validation that pyplot commands are documented#24000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
timhoffm merged 1 commit intomatplotlib:mainfromtimhoffm:pyplot-test
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletionsdoc/api/next_api_changes/deprecations/24000-TH.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
``matplotlib.pyplot.get_plot_commands``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

... is a pending deprecation. This is considered internal and no end-user
should need it.
17 changes: 10 additions & 7 deletionslib/matplotlib/pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2028,20 +2028,23 @@ def thetagrids(angles=None, labels=None, fmt=None, **kwargs):
return lines, labels


_NON_PLOT_COMMANDS = {
'connect', 'disconnect', 'get_current_fig_manager', 'ginput',
'new_figure_manager', 'waitforbuttonpress'}


@_api.deprecated("3.7", pending=True)
def get_plot_commands():
"""
Get a sorted list of all of the plotting commands.
"""
NON_PLOT_COMMANDS = {
'connect', 'disconnect', 'get_current_fig_manager', 'ginput',
'new_figure_manager', 'waitforbuttonpress'}
return (name for name in _get_pyplot_commands()
if name not in NON_PLOT_COMMANDS)


def _get_pyplot_commands():
# This works by searching for all functions in this module and removing
# a few hard-coded exclusions, as well as all of the colormap-setting
# functions, and anything marked as private with a preceding underscore.
exclude = {'colormaps', 'colors', 'get_plot_commands',
*_NON_PLOT_COMMANDS, *colormaps}
exclude = {'colormaps', 'colors', 'get_plot_commands', *colormaps}
this_module = inspect.getmodule(get_plot_commands)
return sorted(
name for name, obj in globals().items()
Expand Down
41 changes: 36 additions & 5 deletionslib/matplotlib/tests/test_pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
import difflib
import re

import numpy as np
import subprocess
Expand DownExpand Up@@ -367,10 +366,42 @@ def test_doc_pyplot_summary():
if not pyplot_docs.exists():
pytest.skip("Documentation sources not available")

lines = pyplot_docs.read_text()
m = re.search(r':nosignatures:\n\n(.*?)\n\n', lines, re.DOTALL)
doc_functions = set(line.strip() for line in m.group(1).split('\n'))
plot_commands = set(plt.get_plot_commands())
def extract_documented_functions(lines):
"""
Return a list of all the functions that are mentioned in the
autosummary blocks contained in *lines*.

An autosummary block looks like this::

.. autosummary::
:toctree: _as_gen
:template: autosummary.rst
:nosignatures:

plot
plot_date

"""
functions = []
in_autosummary = False
for line in lines:
if not in_autosummary:
if line.startswith(".. autosummary::"):
in_autosummary = True
else:
if not line or line.startswith(" :"):
# empty line or autosummary parameter
continue
if not line[0].isspace():
# no more indentation: end of autosummary block
in_autosummary = False
continue
functions.append(line.strip())
return functions

lines = pyplot_docs.read_text().split("\n")
doc_functions = set(extract_documented_functions(lines))
plot_commands = set(plt._get_pyplot_commands())
missing = plot_commands.difference(doc_functions)
if missing:
raise AssertionError(
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp