A "blended" transform uses one transform for the *x*-direction, and another transform for the *y*-direction. This version is an optimization for the case where both child transforms are of type `Affine2DBase`.
| 2322 | |
| 2323 | |
| 2324 | class BlendedAffine2D(_BlendedMixin, Affine2DBase): |
| 2325 | """ |
| 2326 | A "blended" transform uses one transform for the *x*-direction, and |
| 2327 | another transform for the *y*-direction. |
| 2328 | |
| 2329 | This version is an optimization for the case where both child |
| 2330 | transforms are of type `Affine2DBase`. |
| 2331 | """ |
| 2332 | |
| 2333 | is_separable = True |
| 2334 | |
| 2335 | def __init__(self, x_transform, y_transform, **kwargs): |
| 2336 | """ |
| 2337 | Create a new "blended" transform using *x_transform* to transform the |
| 2338 | *x*-axis and *y_transform* to transform the *y*-axis. |
| 2339 | |
| 2340 | Both *x_transform* and *y_transform* must be 2D affine transforms. |
| 2341 | |
| 2342 | You will generally not call this constructor directly but use the |
| 2343 | `blended_transform_factory` function instead, which can determine |
| 2344 | automatically which kind of blended transform to create. |
| 2345 | """ |
| 2346 | is_affine = x_transform.is_affine and y_transform.is_affine |
| 2347 | is_separable = x_transform.is_separable and y_transform.is_separable |
| 2348 | is_correct = is_affine and is_separable |
| 2349 | if not is_correct: |
| 2350 | raise ValueError("Both *x_transform* and *y_transform* must be 2D " |
| 2351 | "affine transforms") |
| 2352 | |
| 2353 | Transform.__init__(self, **kwargs) |
| 2354 | self._x = x_transform |
| 2355 | self._y = y_transform |
| 2356 | self.set_children(x_transform, y_transform) |
| 2357 | |
| 2358 | Affine2DBase.__init__(self) |
| 2359 | self._mtx = None |
| 2360 | |
| 2361 | def get_matrix(self): |
| 2362 | # docstring inherited |
| 2363 | if self._invalid: |
| 2364 | if self._x == self._y: |
| 2365 | self._mtx = self._x.get_matrix() |
| 2366 | else: |
| 2367 | x_mtx = self._x.get_matrix() |
| 2368 | y_mtx = self._y.get_matrix() |
| 2369 | # We already know the transforms are separable, so we can skip |
| 2370 | # setting b and c to zero. |
| 2371 | self._mtx = np.array([x_mtx[0], y_mtx[1], [0.0, 0.0, 1.0]]) |
| 2372 | self._inverted = None |
| 2373 | self._invalid = 0 |
| 2374 | return self._mtx |
| 2375 | |
| 2376 | |
| 2377 | def blended_transform_factory(x_transform, y_transform): |
no outgoing calls
no test coverage detected
searching dependent graphs…