Skip to content

Commit fd5c9fe

Browse files
committed
FIX
1 parent 50a1c8b commit fd5c9fe

File tree

5 files changed

+8
-43
lines changed

5 files changed

+8
-43
lines changed

lib/matplotlib/_tight_bbox.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from matplotlib.transforms import Bbox, TransformedBbox, Affine2D
66

7-
import numpy as np
87

98
def adjust_bbox(fig, bbox_inches, fixed_dpi=None):
109
"""
@@ -58,12 +57,8 @@ def restore_bbox():
5857
dpi_scale = fixed_dpi / fig.dpi
5958

6059
fig.bbox_inches = Bbox.from_bounds(0, 0, *bbox_inches.size)
61-
print(bbox_inches.p0)
62-
x0 = np.floor(bbox_inches.p0[0]*fig.dpi * dpi_scale)
63-
y0 = np.floor(bbox_inches.p0[1]*fig.dpi * dpi_scale)
64-
# x0, y0 = tr.transform(bbox_inches.p0)
60+
x0, y0 = tr.transform(bbox_inches.p0)
6561
w1, h1 = fig.bbox.size * dpi_scale
66-
print('x0, y0, w1, h1', x0, y0, w1, h1, fig.bbox)
6762
fig.transFigure._boxout = Bbox.from_bounds(-x0, -y0, w1, h1)
6863
fig.transFigure.invalidate()
6964

lib/matplotlib/cbook.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1277,10 +1277,7 @@ def _to_unmasked_float_array(x):
12771277
if hasattr(x, 'mask'):
12781278
return np.ma.asarray(x, float).filled(np.nan)
12791279
else:
1280-
try:
1281-
return np.asarray(x, float)
1282-
except TypeError:
1283-
return np.asarray([float(xx) for xx in x])
1280+
return np.asarray(x, float)
12841281

12851282

12861283
def _check_1d(x):

lib/matplotlib/sphinxext/plot_directive.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def setup(app):
306306
app.add_config_value('plot_apply_rcparams', False, True)
307307
app.add_config_value('plot_working_directory', None, True)
308308
app.add_config_value('plot_template', None, True)
309-
app.add_config_value('plot_srcset', None, True)
309+
app.add_config_value('plot_srcset', [], True)
310310
app.connect('doctree-read', mark_plot_labels)
311311
app.add_css_file('plot_directive.css')
312312
app.connect('build-finished', _copy_css_file)
@@ -596,7 +596,7 @@ def _parse_srcset(entries):
596596
mult = entry[:-1]
597597
srcset[float(mult)] = entry
598598
else:
599-
raise ExtensionError('srcset argument "{entry}" is invalid.')
599+
raise ExtensionError('srcset argument {entry!r} is invalid.')
600600
return srcset
601601

602602

@@ -703,8 +703,8 @@ def render_figures(code, code_path, output_dir, output_base, context,
703703
if fmt == formats[0][0] and config.plot_srcset:
704704
# save a 2x, 3x etc version of the default...
705705
srcset = _parse_srcset(config.plot_srcset)
706-
for mult in srcset:
707-
fm = srcset[mult] + '.' + fmt
706+
for mult, suffix in srcset.items():
707+
fm = f'{suffix}.{fmt}'
708708
img.formats.append(fm)
709709
figman.canvas.figure.savefig(img.filename(fm),
710710
dpi=int(dpi * mult))
@@ -876,7 +876,7 @@ def run(arguments, content, options, state_machine, state, lineno):
876876

877877
# Properly indent the caption
878878
if caption and config.plot_srcset:
879-
caption = ':caption: ' + caption
879+
caption = f':caption: {caption}'
880880
elif caption:
881881
caption = '\n' + '\n'.join(' ' + line.strip()
882882
for line in caption.split('\n'))

lib/matplotlib/tests/test_sphinxext.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def test_srcset_version(tmp_path):
192192
doctree_dir = tmp_path / 'doctrees'
193193

194194
build_sphinx_html(tmp_path, doctree_dir, html_dir, extra_args=[
195-
'-c', f'{tmp_path}/confSrcset/'])
195+
'-D', 'plot_srcset=2x'])
196196

197197
def plot_file(num, suff=''):
198198
return img_dir / f'some_plots-{num}{suff}.png'

lib/matplotlib/tests/tinypages/confSrcset/conf.py

-27
This file was deleted.

0 commit comments

Comments
 (0)