()
| 368 | |
| 369 | |
| 370 | def test_non_affine_caching(): |
| 371 | class AssertingNonAffineTransform(mtransforms.Transform): |
| 372 | """ |
| 373 | This transform raises an assertion error when called when it |
| 374 | shouldn't be and ``self.raise_on_transform`` is True. |
| 375 | |
| 376 | """ |
| 377 | input_dims = output_dims = 2 |
| 378 | is_affine = False |
| 379 | |
| 380 | def __init__(self, *args, **kwargs): |
| 381 | super().__init__(*args, **kwargs) |
| 382 | self.raise_on_transform = False |
| 383 | self.underlying_transform = mtransforms.Affine2D().scale(10, 10) |
| 384 | |
| 385 | def transform_path_non_affine(self, path): |
| 386 | assert not self.raise_on_transform, \ |
| 387 | 'Invalidated affine part of transform unnecessarily.' |
| 388 | return self.underlying_transform.transform_path(path) |
| 389 | transform_path = transform_path_non_affine |
| 390 | |
| 391 | def transform_non_affine(self, path): |
| 392 | assert not self.raise_on_transform, \ |
| 393 | 'Invalidated affine part of transform unnecessarily.' |
| 394 | return self.underlying_transform.transform(path) |
| 395 | transform = transform_non_affine |
| 396 | |
| 397 | my_trans = AssertingNonAffineTransform() |
| 398 | ax = plt.axes() |
| 399 | plt.plot(np.arange(10), transform=my_trans + ax.transData) |
| 400 | plt.draw() |
| 401 | # enable the transform to raise an exception if it's non-affine transform |
| 402 | # method is triggered again. |
| 403 | my_trans.raise_on_transform = True |
| 404 | ax.transAxes.invalidate() |
| 405 | plt.draw() |
| 406 | |
| 407 | |
| 408 | def test_external_transform_api(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…