MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_draw

Function test_draw

lib/matplotlib/tests/test_backend_bases.py:333–360  ·  view source on GitHub ↗
(backend)

Source from the content-addressed store, hash-verified

331 pytest.param('pgf', marks=needs_pgf_xelatex)]
332)
333def test_draw(backend):
334 from matplotlib.figure import Figure
335 from matplotlib.backends.backend_agg import FigureCanvas
336 test_backend = importlib.import_module(f'matplotlib.backends.backend_{backend}')
337 TestCanvas = test_backend.FigureCanvas
338 fig_test = Figure(constrained_layout=True)
339 TestCanvas(fig_test)
340 axes_test = fig_test.subplots(2, 2)
341
342 # defaults to FigureCanvasBase
343 fig_agg = Figure(constrained_layout=True)
344 # put a backends.backend_agg.FigureCanvas on it
345 FigureCanvas(fig_agg)
346 axes_agg = fig_agg.subplots(2, 2)
347
348 init_pos = [ax.get_position() for ax in axes_test.ravel()]
349
350 fig_test.canvas.draw()
351 fig_agg.canvas.draw()
352
353 layed_out_pos_test = [ax.get_position() for ax in axes_test.ravel()]
354 layed_out_pos_agg = [ax.get_position() for ax in axes_agg.ravel()]
355
356 for init, placed in zip(init_pos, layed_out_pos_test):
357 assert not np.allclose(init, placed, atol=0.005)
358
359 for ref, test in zip(layed_out_pos_agg, layed_out_pos_test):
360 np.testing.assert_allclose(ref, test, atol=0.005)
361
362
363@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 5

FigureClass · 0.90
allcloseMethod · 0.80
subplotsMethod · 0.45
get_positionMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…