()
| 142 | |
| 143 | |
| 144 | def test_noop_tight_bbox(): |
| 145 | from PIL import Image |
| 146 | x_size, y_size = (10, 7) |
| 147 | dpi = 100 |
| 148 | # make the figure just the right size up front |
| 149 | fig = plt.figure(frameon=False, dpi=dpi, figsize=(x_size/dpi, y_size/dpi)) |
| 150 | ax = fig.add_axes((0, 0, 1, 1)) |
| 151 | ax.set_axis_off() |
| 152 | ax.xaxis.set_visible(False) |
| 153 | ax.yaxis.set_visible(False) |
| 154 | |
| 155 | data = np.arange(x_size * y_size).reshape(y_size, x_size) |
| 156 | ax.imshow(data, rasterized=True) |
| 157 | |
| 158 | # When a rasterized Artist is included, a mixed-mode renderer does |
| 159 | # additional bbox adjustment. It should also be a no-op, and not affect the |
| 160 | # next save. |
| 161 | fig.savefig(BytesIO(), bbox_inches='tight', pad_inches=0, format='pdf') |
| 162 | |
| 163 | out = BytesIO() |
| 164 | fig.savefig(out, bbox_inches='tight', pad_inches=0) |
| 165 | out.seek(0) |
| 166 | im = np.asarray(Image.open(out)) |
| 167 | assert (im[:, :, 3] == 255).all() |
| 168 | assert not (im[:, :, :3] == 255).all() |
| 169 | assert im.shape == (7, 10, 4) |
| 170 | |
| 171 | |
| 172 | @image_comparison(['bbox_inches_fixed_aspect.png'], remove_text=True, |
nothing calls this directly
no test coverage detected
searching dependent graphs…