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

Class CompositeGenericTransform

lib/matplotlib/transforms.py:2391–2502  ·  view source on GitHub ↗

A composite transform formed by applying transform *a* then transform *b*. This "generic" version can handle any two arbitrary transformations.

Source from the content-addressed store, hash-verified

2389
2390
2391class CompositeGenericTransform(Transform):
2392 """
2393 A composite transform formed by applying transform *a* then
2394 transform *b*.
2395
2396 This "generic" version can handle any two arbitrary
2397 transformations.
2398 """
2399 pass_through = True
2400
2401 def __init__(self, a, b, **kwargs):
2402 """
2403 Create a new composite transform that is the result of
2404 applying transform *a* then transform *b*.
2405
2406 You will generally not call this constructor directly but write ``a +
2407 b`` instead, which will automatically choose the best kind of composite
2408 transform instance to create.
2409 """
2410 if a.output_dims != b.input_dims:
2411 raise ValueError("The output dimension of 'a' must be equal to "
2412 "the input dimensions of 'b'")
2413 self.input_dims = a.input_dims
2414 self.output_dims = b.output_dims
2415
2416 super().__init__(**kwargs)
2417 self._a = a
2418 self._b = b
2419 self.set_children(a, b)
2420
2421 def frozen(self):
2422 # docstring inherited
2423 self._invalid = 0
2424 frozen = composite_transform_factory(
2425 self._a.frozen(), self._b.frozen())
2426 if not isinstance(frozen, CompositeGenericTransform):
2427 return frozen.frozen()
2428 return frozen
2429
2430 def _invalidate_internal(self, level, invalidating_node):
2431 # When the left child is invalidated at AFFINE_ONLY level and the right child is
2432 # non-affine, the composite transform is FULLY invalidated.
2433 if invalidating_node is self._a and not self._b.is_affine:
2434 level = Transform._INVALID_FULL
2435 super()._invalidate_internal(level, invalidating_node)
2436
2437 def __eq__(self, other):
2438 if isinstance(other, (CompositeGenericTransform, CompositeAffine2D)):
2439 return self is other or (self._a == other._a
2440 and self._b == other._b)
2441 else:
2442 return False
2443
2444 def _iter_break_from_left_to_right(self):
2445 for left, right in self._a._iter_break_from_left_to_right():
2446 yield left, right + self._b
2447 for left, right in self._b._iter_break_from_left_to_right():
2448 yield self._a + left, right

Callers 2

invertedMethod · 0.85

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…