@@ -96,8 +96,66 @@ and then use ``rng`` when generating the random numbers.
96
96
97
97
The seed is John Hunter's birthday.
98
98
99
- Writing an image comparison test
100
- --------------------------------
99
+ Image Comparison tests
100
+ ----------------------
101
+
102
+ As noted in :ref: `coding_guidelines-API_changes ` we consider any changes to the
103
+ visual output of Matplotlib to be an API change. To ensure that our visual
104
+ output is consistent we make heavy use of image comparison tests in the
105
+ automated test suites. By default, and with only a few exceptions, the tests
106
+ compare the expected and test output with zero tolerance which means the output
107
+ of Matplotlib is stable at the pixel level across time, platform, and
108
+ architecture.
109
+
110
+ For Agg, which directly produces raster output, we directly compare the output
111
+ with saved png. For vector outputs we use an external tool (inkscape for svg
112
+ and ghostscript for eps/pdf) to convert both the baseline and test image to a
113
+ raster that we can compare. However, different versions of FreeType slightly
114
+ shift the placement and size of the rendered text which in turn causes our
115
+ tests to fail. Thus, we have historically run the test suite with a fixed
116
+ version of FreeType.
117
+
118
+ In the past we stored a complete set of the test images, against a specific
119
+ version of FreeType, in the main source repository. While highly effective,
120
+ this was not a sustainable over the long term as the pinned version of FreeType
121
+ will eventually need to be updated. Further, while our wheels are built with
122
+ the pinned version of FreeType, most other down-stream packages (such as
123
+ conda-forge and the Linux distributions) use what ever their currently
124
+ supported Freetype is this many of our users are using a version of FreeType
125
+ that we do not test.
126
+
127
+ We now use a combination of testing for self-consistency with files generated
128
+ on a developers computer and sets of canonical baseline images generated with
129
+ every release.
130
+
131
+
132
+ Generate local baseline images from upstream branch
133
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
134
+
135
+
136
+ Adding a test image
137
+ ^^^^^^^^^^^^^^^^^^^
138
+
139
+
140
+ Update a test image
141
+ ^^^^^^^^^^^^^^^^^^^
142
+
143
+
144
+ Build Matplotlib with a specific FreeType
145
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146
+
147
+
148
+ Fetch the baseline images for a Matplotlib Release and FreeType version
149
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150
+
151
+
152
+ Generate the baseline images for a Matplotlib Release and FreeType version
153
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
154
+
155
+
156
+
157
+ Writing an image comparison test [TODO fix]
158
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
101
159
102
160
Writing an image-based test is only slightly more difficult than a simple
103
161
test. The main consideration is that you must specify the "baseline", or
@@ -140,6 +198,7 @@ See the documentation of `~matplotlib.testing.decorators.image_comparison` and
140
198
`~matplotlib.testing.decorators.check_figures_equal ` for additional information
141
199
about their use.
142
200
201
+
143
202
Creating a new module in matplotlib.tests
144
203
-----------------------------------------
145
204
0 commit comments