|
7 | 7 | test_plot_phylo_nams) |
8 | 8 | import os |
9 | 9 | import shutil |
10 | | -import helper_functions |
| 10 | +import matplotlib |
| 11 | +from matplotlib.testing.compare import compare_images |
| 12 | +matplotlib.use('Agg') |
| 13 | + |
| 14 | + |
| 15 | +plt.rcParams.update({ |
| 16 | + 'font.family': 'DejaVu Sans', |
| 17 | + 'figure.dpi': 100 # Set a fixed DPI |
| 18 | +}) |
11 | 19 |
|
12 | 20 |
|
13 | 21 | # Tests all parameters with plot_phylo with three different trees |
@@ -45,8 +53,6 @@ def test_plot_phylo_params(xpos, |
45 | 53 |
|
46 | 54 | f = plt.figure(figsize=(10, 20)) |
47 | 55 | a = f.add_subplot(111) |
48 | | - a.set_xlim(-10, 20) |
49 | | - a.set_ylim(-1, ylim) |
50 | 56 | plot_phylo.plot_phylo(tree=tree, ax=a, |
51 | 57 | xpos=xpos, |
52 | 58 | ypos=ypos, |
@@ -80,14 +86,12 @@ def test_plot_phylo_params(xpos, |
80 | 86 |
|
81 | 87 | exp = expected_figure.replace(".png", "_%s.png" % tree_stem) |
82 | 88 | # Compare the Matplotlib figures as images |
83 | | - result, f1, f2 = helper_functions.compare_images( |
84 | | - "test_temp/%s_%s.png" % (ID, tree_stem), |
85 | | - exp, tol=1) |
86 | | - f1.save(f"test_temp/f1_{ID}_{tree_stem}_frag.png") |
87 | | - f2.save(f"test_temp/f2_{ID}_{tree_stem}_frag.png") |
88 | | - # shutil.rmtree("test_temp") |
| 89 | + result = compare_images("test_temp/%s_%s.png" % (ID, tree_stem), |
| 90 | + exp, tol=0.01) |
| 91 | + |
| 92 | + shutil.rmtree("test_temp") |
89 | 93 | # Assert that the images are similar |
90 | | - assert result |
| 94 | + assert result is None |
91 | 95 |
|
92 | 96 |
|
93 | 97 | @pytest.mark.parametrize(test_plot_phylo_vars, |
@@ -119,8 +123,6 @@ def test_bad_tree(xpos, |
119 | 123 | auto_ax): |
120 | 124 | f = plt.figure(figsize=(10, 20)) |
121 | 125 | a = f.add_subplot(111) |
122 | | - a.set_xlim(-10, 20) |
123 | | - a.set_ylim(-1, ylim) |
124 | 126 | with pytest.raises(RuntimeError, |
125 | 127 | match="Error in parsing Newick"): |
126 | 128 | plot_phylo.plot_phylo(tree=tree, ax=a, |
|
0 commit comments