(backend)
| 331 | pytest.param('pgf', marks=needs_pgf_xelatex)] |
| 332 | ) |
| 333 | def 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( |
nothing calls this directly
no test coverage detected
searching dependent graphs…