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

Appearance settings

Commit f6b15c5

Browse filesBrowse files
committed
Fix format parsing
1 parent 43c66e1 commit f6b15c5
Copy full SHA for f6b15c5

File tree

Expand file treeCollapse file tree

1 file changed

+17
-18
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+17
-18
lines changed

‎lib/matplotlib/sphinxext/plot_directive.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/plot_directive.py
+17-18Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -537,16 +537,7 @@ def clear_state(plot_rcparams, close=True):
537537
matplotlib.rcParams.update(plot_rcparams)
538538

539539

540-
def render_figures(code, code_path, output_dir, output_base, context,
541-
function_name, config, context_reset=False,
542-
close_figs=False):
543-
"""
544-
Run a pyplot script and save the images in *output_dir*.
545-
546-
Save the images under *output_dir* with file names derived from
547-
*output_base*
548-
"""
549-
# -- Parse format list
540+
def get_plot_formats(config):
550541
default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 200}
551542
formats = []
552543
plot_formats = config.plot_formats
@@ -562,10 +553,23 @@ def render_figures(code, code_path, output_dir, output_base, context,
562553
formats.append((str(suffix), int(dpi)))
563554
else:
564555
formats.append((fmt, default_dpi.get(fmt, 80)))
565-
elif type(fmt) in (tuple, list) and len(fmt)==2:
556+
elif type(fmt) in (tuple, list) and len(fmt) == 2:
566557
formats.append((str(fmt[0]), int(fmt[1])))
567558
else:
568559
raise PlotError('invalid image format "%r" in plot_formats' % fmt)
560+
return formats
561+
562+
563+
def render_figures(code, code_path, output_dir, output_base, context,
564+
function_name, config, context_reset=False,
565+
close_figs=False):
566+
"""
567+
Run a pyplot script and save the images in *output_dir*.
568+
569+
Save the images under *output_dir* with file names derived from
570+
*output_base*
571+
"""
572+
formats = get_plot_formats(config)
569573

570574
# -- Try to determine if all images already exist
571575

@@ -665,13 +669,8 @@ def run(arguments, content, options, state_machine, state, lineno):
665669
config = document.settings.env.config
666670
nofigs = 'nofigs' in options
667671

668-
plot_formats = config.plot_formats
669-
if isinstance(plot_formats, six.string_types):
670-
# String Sphinx < 1.3, Split on , to mimic
671-
# Sphinx 1.3 and later. Sphinx 1.3 always
672-
# returns a list.
673-
plot_formats = plot_formats.split(',')
674-
default_fmt = plot_formats[0][0]
672+
formats = get_plot_formats(config)
673+
default_fmt = formats[0][0]
675674

676675
options.setdefault('include-source', config.plot_include_source)
677676
keep_context = 'context' in options

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.