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

Function _collect_new_figures

lib/matplotlib/testing/decorators.py:79–98  ·  view source on GitHub ↗

After:: with _collect_new_figures() as figs: some_code() the list *figs* contains the figures that have been created during the execution of ``some_code``, sorted by figure number.

()

Source from the content-addressed store, hash-verified

77
78@contextlib.contextmanager
79def _collect_new_figures():
80 """
81 After::
82
83 with _collect_new_figures() as figs:
84 some_code()
85
86 the list *figs* contains the figures that have been created during the
87 execution of ``some_code``, sorted by figure number.
88 """
89 managers = _pylab_helpers.Gcf.figs
90 preexisting = [manager for manager in managers.values()]
91 new_figs = []
92 try:
93 yield new_figs
94 finally:
95 new_managers = sorted([manager for manager in managers.values()
96 if manager not in preexisting],
97 key=lambda manager: manager.num)
98 new_figs[:] = [manager.canvas.figure for manager in new_managers]
99
100
101def _raise_on_image_difference(expected, actual, tol):

Callers 1

wrapperFunction · 0.85

Calls 1

valuesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…