MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_image_bounds_handling

Function test_image_bounds_handling

lib/matplotlib/tests/test_image.py:1972–1999  ·  view source on GitHub ↗
(nonaffine_identity)

Source from the content-addressed store, hash-verified

1970
1971@image_comparison(['image_bounds_handling.png'], style='_classic_test', tol=0.006)
1972def test_image_bounds_handling(nonaffine_identity):
1973 # TODO: The second and third panels in the bottom row show that the handling of
1974 # image bounds is bugged for non-affine transforms and non-nearest-neighbor
1975 # interpolation. If this bug gets fixed, the baseline image should be updated.
1976
1977 fig, axs = plt.subplots(2, 3)
1978
1979 N = 11
1980
1981 for j, interpolation in enumerate(['nearest', 'hanning', 'bilinear']):
1982 data = np.arange(N**2).reshape((N, N))
1983 data = data / N**2 + (data % 4) / 6
1984 rotation = Affine2D().rotate_around(N/2-0.5, N/2-0.5, 1)
1985
1986 for i in range(2):
1987 transform = rotation + axs[i, j].transData
1988 if i == 1:
1989 # Bottom row uses a non-affine transform
1990 transform = nonaffine_identity + transform
1991
1992 axs[i, j].imshow(data, cmap='Grays', interpolation=interpolation,
1993 transform=transform)
1994
1995 axs[i, j].set_axis_off()
1996 box = Rectangle((-0.5, -0.5), N, N,
1997 edgecolor='red', facecolor='none', lw=0.5, ls='dashed',
1998 transform=rotation + axs[i, j].transData)
1999 axs[i, j].add_artist(box)
2000
2001
2002@image_comparison(['rgba_clean_edges.png'], style='_classic_test', tol=0.003)

Callers

nothing calls this directly

Calls 7

Affine2DClass · 0.90
RectangleClass · 0.90
rotate_aroundMethod · 0.80
imshowMethod · 0.80
subplotsMethod · 0.45
set_axis_offMethod · 0.45
add_artistMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…