Skip to content

Commit 491ca45

Browse files
SaimMomin12adRn-s
authored andcommitted
Replace file size test with compare image
1 parent 335b8ee commit 491ca45

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

13 Bytes
Loading

pydeeptools/deeptools/test/test_plotcorrelation.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os.path
44
from os import unlink
5+
from matplotlib.testing.compare import compare_images
56

67

78
ROOT = os.path.dirname(os.path.abspath(__file__)) + "/test_data/"
@@ -26,11 +27,8 @@ def test_correlation_plot_with_minimal_options():
2627
expected = "'bowtie2 test1.bam'\t1.0000\t1.0000\n"
2728
assert expected in resp, f"'{expected}' not found in '{resp}'"
2829

29-
png_file_size = os.path.getsize(COR_PLOT_1)
30-
expected_file_size = os.path.getsize(out_png)
31-
size_tolerance = 5000
32-
size_difference = abs(png_file_size - expected_file_size)
33-
assert size_difference <= size_tolerance, "File size do not match"
30+
res = compare_images(COR_PLOT_1, out_png, 50)
31+
assert res is None, "Plots do not match"
3432
unlink(out_png)
3533

3634

@@ -41,9 +39,7 @@ def test_correlation_plot_scatter():
4139
out_png2 = '/tmp/correlation_plot2.png'
4240
args = "--corData {} -p scatterplot -c pearson -o {}".format(COR_DATA_IN1, out_png2).split()
4341
pc.main(args)
44-
png_file_size = os.path.getsize(COR_PLOT_2)
45-
expected_file_size = os.path.getsize(out_png2)
46-
size_tolerance = 5000
47-
size_difference = abs(png_file_size - expected_file_size)
48-
assert size_difference <= size_tolerance, "File size do not match"
42+
43+
res = compare_images(COR_PLOT_2, out_png2, 50)
44+
assert res is None, "Plots do not match"
4945
unlink(out_png2)

0 commit comments

Comments
 (0)