A "blended" transform uses one transform for the *x*-direction, and another transform for the *y*-direction. This "generic" version can handle any given child transform in the *x*- and *y*-directions.
| 2229 | |
| 2230 | |
| 2231 | class BlendedGenericTransform(_BlendedMixin, Transform): |
| 2232 | """ |
| 2233 | A "blended" transform uses one transform for the *x*-direction, and |
| 2234 | another transform for the *y*-direction. |
| 2235 | |
| 2236 | This "generic" version can handle any given child transform in the |
| 2237 | *x*- and *y*-directions. |
| 2238 | """ |
| 2239 | input_dims = 2 |
| 2240 | output_dims = 2 |
| 2241 | is_separable = True |
| 2242 | pass_through = True |
| 2243 | |
| 2244 | def __init__(self, x_transform, y_transform, **kwargs): |
| 2245 | """ |
| 2246 | Create a new "blended" transform using *x_transform* to transform the |
| 2247 | *x*-axis and *y_transform* to transform the *y*-axis. |
| 2248 | |
| 2249 | You will generally not call this constructor directly but use the |
| 2250 | `blended_transform_factory` function instead, which can determine |
| 2251 | automatically which kind of blended transform to create. |
| 2252 | """ |
| 2253 | Transform.__init__(self, **kwargs) |
| 2254 | self._x = x_transform |
| 2255 | self._y = y_transform |
| 2256 | self.set_children(x_transform, y_transform) |
| 2257 | self._affine = None |
| 2258 | |
| 2259 | @property |
| 2260 | def depth(self): |
| 2261 | return max(self._x.depth, self._y.depth) |
| 2262 | |
| 2263 | def contains_branch(self, other): |
| 2264 | # A blended transform cannot possibly contain a branch from two |
| 2265 | # different transforms. |
| 2266 | return False |
| 2267 | |
| 2268 | is_affine = property(lambda self: self._x.is_affine and self._y.is_affine) |
| 2269 | has_inverse = property( |
| 2270 | lambda self: self._x.has_inverse and self._y.has_inverse) |
| 2271 | |
| 2272 | def frozen(self): |
| 2273 | # docstring inherited |
| 2274 | return blended_transform_factory(self._x.frozen(), self._y.frozen()) |
| 2275 | |
| 2276 | def transform_non_affine(self, values): |
| 2277 | # docstring inherited |
| 2278 | if self._x.is_affine and self._y.is_affine: |
| 2279 | return values |
| 2280 | x = self._x |
| 2281 | y = self._y |
| 2282 | |
| 2283 | if x == y and x.input_dims == 2: |
| 2284 | return x.transform_non_affine(values) |
| 2285 | |
| 2286 | if x.input_dims == 2: |
| 2287 | x_points = x.transform_non_affine(values)[:, 0:1] |
| 2288 | else: |
no outgoing calls
no test coverage detected
searching dependent graphs…