()
| 1246 | |
| 1247 | @mpl.style.context('mpl20') |
| 1248 | def test_exact_vmin(): |
| 1249 | cmap = mpl.colormaps["autumn_r"].with_extremes(under="lightgrey") |
| 1250 | |
| 1251 | # make the image exactly 190 pixels wide |
| 1252 | fig = plt.figure(figsize=(1.9, 0.1), dpi=100) |
| 1253 | ax = fig.add_axes((0, 0, 1, 1)) |
| 1254 | |
| 1255 | data = np.array( |
| 1256 | [[-1, -1, -1, 0, 0, 0, 0, 43, 79, 95, 66, 1, -1, -1, -1, 0, 0, 0, 34]], |
| 1257 | dtype=float, |
| 1258 | ) |
| 1259 | |
| 1260 | im = ax.imshow(data, aspect="auto", cmap=cmap, vmin=0, vmax=100) |
| 1261 | ax.axis("off") |
| 1262 | fig.canvas.draw() |
| 1263 | |
| 1264 | # get the RGBA slice from the image |
| 1265 | from_image = im.make_image(fig.canvas.renderer)[0][0] |
| 1266 | # expand the input to be 190 long and run through norm / cmap |
| 1267 | direct_computation = ( |
| 1268 | im.cmap(im.norm((data * ([[1]] * 10)).T.ravel())) * 255 |
| 1269 | ).astype(int) |
| 1270 | |
| 1271 | # check than the RBGA values are the same |
| 1272 | assert np.all(from_image == direct_computation) |
| 1273 | |
| 1274 | |
| 1275 | @image_comparison(['image_placement'], extensions=['svg', 'pdf'], |
nothing calls this directly
no test coverage detected
searching dependent graphs…