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

Function test_non_affine_caching

lib/matplotlib/tests/test_transforms.py:370–405  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

368
369
370def 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
408def test_external_transform_api():

Callers

nothing calls this directly

Calls 5

axesMethod · 0.45
plotMethod · 0.45
drawMethod · 0.45
invalidateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…