110
110
from matplotlib.testing.decorators import image_comparison
111
111
import matplotlib.pyplot as plt
112
112
113
- @image_comparison(baseline_images=['spines_axes_positions'])
113
+ @image_comparison(baseline_images=['spines_axes_positions'],
114
+ extensions=['png'])
114
115
def test_spines_axes_positions():
115
116
# SF bug 2852168
116
117
fig = plt.figure()
@@ -128,23 +129,28 @@ it::
128
129
129
130
The first time this test is run, there will be no baseline image to
130
131
compare against, so the test will fail. Copy the output images (in
131
- this case `result_images/test_category/spines_axes_positions.* `) to
132
+ this case `result_images/test_category/spines_axes_positions.png `) to
132
133
the correct subdirectory of `baseline_images ` tree in the source
133
134
directory (in this case
134
- `lib/matplotlib/tests/baseline_images/test_category `). Note carefully
135
- the `.* ` at the end: this will copy only the images we need to include
136
- in the `git ` repository. The files ending in `_pdf.png ` and
137
- `_svg.png ` are converted from the `pdf ` and `svg ` originals on the fly
138
- and do not need to be in the respository. Put these new files under
139
- source code revision control (with `git add `). When rerunning the
140
- tests, they should now pass.
135
+ `lib/matplotlib/tests/baseline_images/test_category `). Put this new
136
+ file under source code revision control (with `git add `). When
137
+ rerunning the tests, they should now pass.
138
+
139
+ The :func: `~matplotlib.testing.decorators.image_comparison ` decorator
140
+ defaults to generating ``png ``, ``pdf `` and ``svg `` output, but in
141
+ interest of keeping the size of the library from ballooning we should only
142
+ include the ``svg `` or ``pdf `` outputs if the test is explicitly exercising
143
+ a feature that this backend dependent.
141
144
142
145
There are two optional keyword arguments to the `image_comparison `
143
146
decorator:
144
147
145
- - `extensions `: If you only wish to test some of the image formats
146
- (rather than the default `png `, `svg ` and `pdf ` formats), pass a
147
- list of the extensions to test.
148
+ - `extensions `: If you only wish to test additional image formats
149
+ (rather than just `png `), pass any additional file types in the
150
+ list list of the extensions to test. When copying the new
151
+ baseline files be sure to only copy the output files, not their
152
+ conversions to ``png ``. For example only copy the files
153
+ ending in ``pdf ``, not in ``_pdf.png ``.
148
154
149
155
- `tol `: This is the image matching tolerance, the default `1e-3 `.
150
156
If some variation is expected in the image between runs, this
0 commit comments