@@ -1243,23 +1243,11 @@ def __init_subclass__(cls):
1243
1243
1244
1244
def __add__ (self , other ):
1245
1245
"""
1246
- Composes two transforms together such that *self* is followed
1247
- by *other*.
1246
+ Compose two transforms together so that *self* is followed by *other*.
1248
1247
"""
1249
- if isinstance (other , Transform ):
1250
- return composite_transform_factory (self , other )
1251
- raise TypeError (
1252
- "Can not add Transform to object of type '%s'" % type (other ))
1253
-
1254
- def __radd__ (self , other ):
1255
- """
1256
- Composes two transforms together such that *self* is followed
1257
- by *other*.
1258
- """
1259
- if isinstance (other , Transform ):
1260
- return composite_transform_factory (other , self )
1261
- raise TypeError (
1262
- "Can not add Transform to object of type '%s'" % type (other ))
1248
+ return (composite_transform_factory (self , other )
1249
+ if isinstance (other , Transform ) else
1250
+ NotImplemented )
1263
1251
1264
1252
# Equality is based on object identity for `Transform`s (so we don't
1265
1253
# override `__eq__`), but some subclasses, such as TransformWrapper &
@@ -2285,9 +2273,9 @@ def __init__(self, a, b, **kwargs):
2285
2273
Create a new composite transform that is the result of
2286
2274
applying transform *a* then transform *b*.
2287
2275
2288
- You will generally not call this constructor directly but use the
2289
- `composite_transform_factory` function instead, which can automatically
2290
- choose the best kind of composite transform instance to create.
2276
+ You will generally not call this constructor directly but write ``a +
2277
+ b`` instead, which will automatically choose the best kind of composite
2278
+ transform instance to create.
2291
2279
"""
2292
2280
if a .output_dims != b .input_dims :
2293
2281
raise ValueError ("The output dimension of 'a' must be equal to "
@@ -2401,13 +2389,11 @@ class CompositeAffine2D(Affine2DBase):
2401
2389
def __init__ (self , a , b , ** kwargs ):
2402
2390
"""
2403
2391
Create a new composite transform that is the result of
2404
- applying transform *a* then transform *b*.
2405
-
2406
- Both *a* and *b* must be instances of :class:`Affine2DBase`.
2392
+ applying `Affine2DBase` *a* then `Affine2DBase` *b*.
2407
2393
2408
- You will generally not call this constructor directly but use the
2409
- `composite_transform_factory` function instead, which can automatically
2410
- choose the best kind of composite transform instance to create.
2394
+ You will generally not call this constructor directly but write ``a +
2395
+ b`` instead, which will automatically choose the best kind of composite
2396
+ transform instance to create.
2411
2397
"""
2412
2398
if not a .is_affine or not b .is_affine :
2413
2399
raise ValueError ("'a' and 'b' must be affine transforms" )
0 commit comments