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

Class AssertingNonAffineTransform

lib/matplotlib/tests/test_transforms.py:371–395  ·  view source on GitHub ↗

This transform raises an assertion error when called when it shouldn't be and ``self.raise_on_transform`` is True.

Source from the content-addressed store, hash-verified

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()

Callers 1

test_non_affine_cachingFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_non_affine_cachingFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…