8000 Misc. style fixes. by anntzer · Pull Request #14533 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 0 additions & 6 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ per-file-ignores =
setup.py: E402
setupext.py: E501

tools/compare_backend_driver_results.py: E501
tools/subset.py: E221, E251, E261, E302, E501

lib/matplotlib/_cm.py: E202, E203, E302
lib/matplotlib/_mathtext_data.py: E203, E261
lib/matplotlib/font_manager.py: E203, E221, E251, E501
lib/matplotlib/mathtext.py: E221, E251
lib/matplotlib/pylab.py: E501
lib/matplotlib/rcsetup.py: E501
lib/matplotlib/tests/test_mathtext.py: E501
lib/matplotlib/transforms.py: E201, E202, E203
Expand All @@ -51,10 +49,6 @@ per-file-ignores =
lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py: E225, E501

doc/conf.py: E402, E501
doc/sphinxext/github.py: E302, E501
doc/sphinxext/math_symbol_table.py: E302, E501
doc/sphinxext/skip_deprecated.py: E302
doc/users/generate_credits.py: E302, E501
tutorials/advanced/path_tutorial.py: E402, E501
tutorials/advanced/patheffects_guide.py: E402, E501
tutorials/advanced/transforms_tutorial.py: E402, E501
Expand Down
13 changes: 10 additions & 3 deletions doc/sphinxext/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from docutils import nodes, utils
from docutils.parsers.rst.roles import set_classes


def make_link_node(rawtext, app, type, slug, options):
"""Create a link to a github resource.

Expand All @@ -37,7 +38,8 @@ def make_link_node(rawtext, app, type, slug, options):
if not base.endswith('/'):
base += '/'
except AttributeError as err:
raise ValueError('github_project_url configuration value is not set (%s)' % str(err))
raise ValueError(
f'github_project_url configuration value is not set ({err})')

ref = base + type + '/' + slug + '/'
set_classes(options)
Expand All @@ -48,6 +50,7 @@ def make_link_node(rawtext, app, type, slug, options):
**options)
return node


def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Link to a GitHub issue.

Expand Down Expand Up @@ -88,6 +91,7 @@ def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
node = make_link_node(rawtext, app, category, str(issue_num), options)
return [node], []


def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Link to a GitHub user.

Expand All @@ -107,7 +111,9 @@ def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
node = nodes.reference(rawtext, text, refuri=ref, **options)
return [node], []

def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):

def ghcommit_role(
name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Link to a GitHub commit.

Returns 2 part tuple containing list of nodes to insert into the
Expand All @@ -130,7 +136,8 @@ def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
if not base.endswith('/'):
base += '/'
except AttributeError as err:
raise ValueError('github_project_url configuration value is not set (%s)' % str(err))
raise ValueError(
f'github_project_url configuration value is not set ({err})')

ref = base + text
node = nodes.reference(rawtext, text[:6], refuri=ref, **options)
Expand Down
9 changes: 7 additions & 2 deletions doc/sphinxext/math_symbol_table.py
Original file line number Diff line number Diff line change
@@ -96,6 +96,7 @@
\iiint \iint \oiiint"""]
]


def run(state_machine):
def get_n(n, l):
part = []
Expand Down Expand Up @@ -135,10 +136,13 @@ def get_n(n, l):
state_machine.insert_input(lines, "Symbol table")
return []

def math_symbol_table_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):

def math_symbol_table_directive(
name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
return run(state_machine)


def setup(app):
app.add_directive(
'math_symbol_table', math_symbol_table_directive,
Expand All @@ -147,6 +151,7 @@ def setup(app):
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
return metadata


if __name__ == "__main__":
# Do some verification of the tables
from matplotlib import _mathtext_data
Expand Down
2 changes: 2 additions & 0 deletions 8000 doc/sphinxext/skip_deprecated.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Skip deprecated members


def skip_deprecated(app, what, name, obj, skip, options):
if skip:
return skip
Expand All @@ -8,6 +9,7 @@ def skip_deprecated(app, what, name, obj, skip, options):
if skip_list is not None:
return getattr(obj, "__name__", None) in skip_list


def setup(app):
app.connect('autodoc-skip-member', skip_deprecated)

Expand Down
4 changes: 3 additions & 1 deletion doc/users/generate_credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
development and usefulness.
"""


def check_duplicates():
text = subprocess.check_output(['git', 'shortlog', '--summary', '--email'])
lines = text.decode('utf8').split('\n')
Expand All @@ -71,7 +72,8 @@ def check_duplicates():
'more than one name.\nConsider adding them to .mailmap.\n')
for email, count in email_counter.items():
if count > 1:
print('%s\n%s' % (email, '\n'.join(l for l in lines if email in l)))
print('{}\n{}'.format(
email, '\n'.join(l for l in lines if email in l)))


def generate_credits():
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/pylab.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
stem - make a stem plot
subplot - make one subplot (numrows, numcols, axesnum)
subplots - make a figure with a set of (numrows, numcols) subplots
subplots_adjust - change the params controlling the subplot positions of current figure
subplots_adjust - control the subplot positions of current figure
subplot_tool - launch the subplot configuration tool
suptitle - add a figure title
table - add a table to the plot
Expand Down
14 changes: 8 additions & 6 deletions tools/compare_backend_driver_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def compare_results(results_a, results_b):
sections = results_a.keys()
sections.sort()
for section in results_a.keys():
print("backend %s" % section)
print(" %-40s %6s %6s %6s %6s" % ("test", "a", "b", "delta", "% diff"))
print(f"backend {section}" % section)
print(f" {'test':40} {'a':>6} {'b':>6} {'delta':>6} {'% diff':>6}")
print(" " + '-' * 69)
deltas = []
section_a = results_a[section]
Expand All @@ -46,7 +46,8 @@ def compare_results(results_a, results_b):
else:
time_a = section_a[test]
time_b = section_b[test]
deltas.append([time_b / time_a, time_b - time_a, time_a, time_b, test])
deltas.append(
[time_b / time_a, time_b - time_a, time_a, time_b, test])
for test in section_b.keys():
if test not in section_a:
deltas.append([None, None, None, section_b[test], test])
Expand All @@ -55,11 +56,12 @@ def compare_results(results_a, results_b):
for diff, delta, time_a, time_b, test in deltas:
if diff is None:
if time_a is None:
print(" %-40s ??? % 6.3f ??? ???" % (test, time_b))
print(f" {test:40} ??? {time_b: 6.3f} ??? ???")
else:
print(" %-40s % 6.3f ??? ??? ???" % (test, time_a))
print(f" {test:40} {time_a: 6.3f} ??? ??? ???")
else:
print(" %-40s % 6.3f % 6.3f % 6.3f %6d%%" % (test, time_a, time_b, delta, diff * 100))
print(f" {test:40} {time_a: 6.3f} {time_b: 6.3f} "
f"{delta: 6.3f} {diff:6.0%}")


if __name__ == '__main__':
Expand Down
0