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

Class CompositeAffine2D

lib/matplotlib/transforms.py:2505–2555  ·  view source on GitHub ↗

A composite transform formed by applying transform *a* then transform *b*. This version is an optimization that handles the case where both *a* and *b* are 2D affines.

Source from the content-addressed store, hash-verified

2503
2504
2505class CompositeAffine2D(Affine2DBase):
2506 """
2507 A composite transform formed by applying transform *a* then transform *b*.
2508
2509 This version is an optimization that handles the case where both *a*
2510 and *b* are 2D affines.
2511 """
2512 def __init__(self, a, b, **kwargs):
2513 """
2514 Create a new composite transform that is the result of
2515 applying `Affine2DBase` *a* then `Affine2DBase` *b*.
2516
2517 You will generally not call this constructor directly but write ``a +
2518 b`` instead, which will automatically choose the best kind of composite
2519 transform instance to create.
2520 """
2521 if not a.is_affine or not b.is_affine:
2522 raise ValueError("'a' and 'b' must be affine transforms")
2523 if a.output_dims != b.input_dims:
2524 raise ValueError("The output dimension of 'a' must be equal to "
2525 "the input dimensions of 'b'")
2526 self.input_dims = a.input_dims
2527 self.output_dims = b.output_dims
2528
2529 super().__init__(**kwargs)
2530 self._a = a
2531 self._b = b
2532 self.set_children(a, b)
2533 self._mtx = None
2534
2535 @property
2536 def depth(self):
2537 return self._a.depth + self._b.depth
2538
2539 def _iter_break_from_left_to_right(self):
2540 for left, right in self._a._iter_break_from_left_to_right():
2541 yield left, right + self._b
2542 for left, right in self._b._iter_break_from_left_to_right():
2543 yield self._a + left, right
2544
2545 __str__ = _make_str_method("_a", "_b")
2546
2547 def get_matrix(self):
2548 # docstring inherited
2549 if self._invalid:
2550 self._mtx = np.dot(
2551 self._b.get_matrix(),
2552 self._a.get_matrix())
2553 self._inverted = None
2554 self._invalid = 0
2555 return self._mtx
2556
2557
2558def composite_transform_factory(a, b):

Callers 1

Calls 1

_make_str_methodFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…