Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8cad8ff

Browse files
committed
Lower tolerance to 0
1 parent 03865b1 commit 8cad8ff

File tree

9 files changed

+20
-18
lines changed

9 files changed

+20
-18
lines changed

lib/matplotlib/testing/compare.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,20 @@ def compare_images(expected, actual, tol, in_decorator=False):
318318
actualImage, expectedImage = crop_to_same(
319319
actual, actualImage, expected, expectedImage)
320320

321+
diff_image = make_test_filename(actual, 'failed-diff')
322+
323+
if tol <= 0.0:
324+
if np.array_equal(expectedImage, actualImage):
325+
return None
326+
321327
# convert to signed integers, so that the images can be subtracted without
322328
# overflow
323329
expectedImage = expectedImage.astype(np.int16)
324330
actualImage = actualImage.astype(np.int16)
325331

326332
rms = calculate_rms(expectedImage, actualImage)
327333

328-
diff_image = make_test_filename(actual, 'failed-diff')
329-
330334
if rms <= tol:
331-
if os.path.exists(diff_image):
332-
os.unlink(diff_image)
333335
return None
334336

335337
save_diff_image(expected, actual, diff_image)

lib/matplotlib/testing/decorators.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def do_test():
252252

253253
yield (do_test,)
254254

255-
def image_comparison(baseline_images=None, extensions=None, tol=13,
255+
def image_comparison(baseline_images=None, extensions=None, tol=0,
256256
freetype_version=None, remove_text=False,
257257
savefig_kwarg=None, style='classic'):
258258
"""
@@ -297,7 +297,6 @@ def image_comparison(baseline_images=None, extensions=None, tol=13,
297297
if desired. Defaults to the 'classic' style.
298298
299299
"""
300-
301300
if baseline_images is None:
302301
raise ValueError('baseline_images must be specified')
303302

lib/matplotlib/tests/test_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def test_polar_coord_annotations():
238238
ax.set_ylim(-20, 20)
239239

240240

241-
@image_comparison(baseline_images=['fill_units'], tol=18, extensions=['png'],
241+
@image_comparison(baseline_images=['fill_units'], extensions=['png'],
242242
savefig_kwarg={'dpi': 60})
243243
def test_fill_units():
244244
from datetime import datetime
@@ -1046,7 +1046,7 @@ def test_markevery_polar():
10461046

10471047

10481048
@image_comparison(baseline_images=['marker_edges'],
1049-
remove_text=True, tol=3)
1049+
remove_text=True)
10501050
def test_marker_edges():
10511051
x = np.linspace(0, 1, 10)
10521052
fig = plt.figure()
@@ -1062,14 +1062,14 @@ def test_marker_edges():
10621062
def test_bar_tick_label_single():
10631063
# From 2516: plot bar with array of string labels for x axis
10641064
ax = plt.gca()
1065-
ax.bar(0, 1 , tick_label='a')
1065+
ax.bar(0, 1, tick_label='0')
10661066

10671067
# Reuse testcase from above for a labeled data test
10681068
data = {"a": 0, "b": 1}
10691069
fig = plt.figure()
10701070
ax = fig.add_subplot(111)
10711071
ax = plt.gca()
1072-
ax.bar("a", "b" , tick_label='a', data=data)
1072+
ax.bar("a", "b", tick_label='0', data=data)
10731073

10741074

10751075
@cleanup

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_hatching_legend():
122122

123123

124124
@image_comparison(baseline_images=['grayscale_alpha'],
125-
extensions=['pdf'], tol=1e-3)
125+
extensions=['pdf'])
126126
def test_grayscale_alpha():
127127
"""Masking images with NaN did not work for grayscale images"""
128128
x, y = np.ogrid[-2:2:.1, -2:2:.1]

lib/matplotlib/tests/test_bbox_tight.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
@image_comparison(baseline_images=['bbox_inches_tight'], remove_text=True,
18-
savefig_kwarg=dict(bbox_inches='tight'), tol=15)
18+
savefig_kwarg=dict(bbox_inches='tight'))
1919
def test_bbox_inches_tight():
2020
#: Test that a figure saved using bbox_inches='tight' is clipped correctly
2121
data = [[ 66386, 174296, 75131, 577908, 32015],
@@ -84,8 +84,8 @@ def test_bbox_inches_tight_clipping():
8484
path.vertices *= 0.25
8585
patch.set_clip_path(path, transform=ax.transAxes)
8686
plt.gcf().artists.append(patch)
87-
88-
87+
88+
8989
@image_comparison(baseline_images=['bbox_inches_tight_raster'],
9090
remove_text=True, savefig_kwarg={'bbox_inches': 'tight'})
9191
def test_bbox_inches_tight_raster():

lib/matplotlib/tests/test_dates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_date_axhline():
7171
fig.subplots_adjust(left=0.25)
7272

7373

74-
@image_comparison(baseline_images=['date_axvline'], tol=16,
74+
@image_comparison(baseline_images=['date_axvline'],
7575
extensions=['png'])
7676
def test_date_axvline():
7777
# test ax hline with date inputs

lib/matplotlib/tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def test_image_composite_alpha():
354354
ax.set_ylim([5, 0])
355355

356356

357-
@image_comparison(baseline_images=['rasterize_10dpi'], extensions=['pdf','svg'], tol=5e-2, remove_text=True)
357+
@image_comparison(baseline_images=['rasterize_10dpi'], extensions=['pdf','svg'], remove_text=True)
358358
def test_rasterize_dpi():
359359
# This test should check rasterized rendering with high output resolution.
360360
# It plots a rasterized line and a normal image with implot. So it will catch

lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@
157157

158158
def make_set(basename, fontset, tests, extensions=None):
159159
def make_test(filename, test):
160-
@image_comparison(baseline_images=[filename], extensions=extensions,
161-
tol=32)
160+
@image_comparison(baseline_images=[filename], extensions=extensions)
162161
def single_test():
163162
matplotlib.rcParams['mathtext.fontset'] = fontset
164163
fig = plt.figure(figsize=(5.25, 0.75))

lib/matplotlib/tests/test_path.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def test_make_compound_path_empty():
9191

9292
@image_comparison(baseline_images=['xkcd'], remove_text=True)
9393
def test_xkcd():
94+
np.random.seed(0)
95+
9496
x = np.linspace(0, 2.0 * np.pi, 100.0)
9597
y = np.sin(x)
9698

0 commit comments

Comments
 (0)