| 1698 | ] |
| 1699 | ) |
| 1700 | def test_resample_nonaffine(data, interpolation, expected, nonaffine_identity): |
| 1701 | # Test that both affine and nonaffine transforms resample to the correct answer |
| 1702 | |
| 1703 | # If the array is constant, the tolerance can be tight |
| 1704 | # Otherwise, the tolerance is limited by the subpixel approach in the agg backend |
| 1705 | atol = 0 if np.all(data == data.ravel()[0]) else 2e-3 |
| 1706 | |
| 1707 | # Create a simple affine transform for scaling the input array |
| 1708 | affine_transform = Affine2D().scale(sx=expected.shape[1] / data.shape[1], sy=1) |
| 1709 | |
| 1710 | affine_result = np.empty_like(expected) |
| 1711 | mimage.resample(data, affine_result, affine_transform, interpolation=interpolation) |
| 1712 | assert_allclose(affine_result, expected, atol=atol) |
| 1713 | |
| 1714 | # Create a nonaffine version of the same transform |
| 1715 | # by compositing with a nonaffine identity transform |
| 1716 | nonaffine_transform = nonaffine_identity + affine_transform |
| 1717 | |
| 1718 | nonaffine_result = np.empty_like(expected) |
| 1719 | mimage.resample(data, nonaffine_result, nonaffine_transform, |
| 1720 | interpolation=interpolation) |
| 1721 | assert_allclose(nonaffine_result, expected, atol=atol) |
| 1722 | |
| 1723 | |
| 1724 | def test_axesimage_get_shape(): |