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

Method compare

lib/matplotlib/testing/decorators.py:154–177  ·  view source on GitHub ↗
(self, fig, baseline, extension, *, _lock=False)

Source from the content-addressed store, hash-verified

152 return expected_fname
153
154 def compare(self, fig, baseline, extension, *, _lock=False):
155 __tracebackhide__ = True
156
157 if self.remove_text:
158 remove_ticks_and_titles(fig)
159
160 actual_path = (self.result_dir / baseline).with_suffix(f'.{extension}')
161 kwargs = self.savefig_kwargs.copy()
162 if extension == 'pdf':
163 kwargs.setdefault('metadata',
164 {'Creator': None, 'Producer': None,
165 'CreationDate': None})
166
167 lock = (cbook._lock_path(actual_path)
168 if _lock else contextlib.nullcontext())
169 with lock:
170 try:
171 fig.savefig(actual_path, **kwargs)
172 finally:
173 # Matplotlib has an autouse fixture to close figures, but this
174 # makes things more convenient for third-party users.
175 plt.close(fig)
176 expected_path = self.copy_baseline(baseline, extension)
177 _raise_on_image_difference(expected_path, actual_path, self.tol)
178
179
180def _pytest_image_comparison(baseline_images, extensions, tol,

Callers 2

test_Type1FontFunction · 0.80
wrapperFunction · 0.80

Calls 6

copy_baselineMethod · 0.95
remove_ticks_and_titlesFunction · 0.85
copyMethod · 0.45
savefigMethod · 0.45
closeMethod · 0.45

Tested by 1

test_Type1FontFunction · 0.64