@@ -1285,8 +1285,30 @@ def transform(self, values):
1285
1285
1286
1286
Accepts a numpy array of shape (N x :attr:`input_dims`) and
1287
1287
returns a numpy array of shape (N x :attr:`output_dims`).
1288
+
1289
+ Alternatively, accepts a numpy array of length :attr:`input_dims`
1290
+ and returns a numpy array of length :attr:`output_dims`.
1288
1291
"""
1289
- return self .transform_affine (self .transform_non_affine (values ))
1292
+ # Ensure that values is a 2d array (but remember whether
1293
+ # we started with a 1d or 2d array).
1294
+ values = np .asanyarray (values )
1295
+ ndim = values .ndim
1296
+ values = values .reshape ((- 1 , self .input_dims ))
1297
+
1298
+ # Transform the values
1299
+ res = self .transform_affine (self .transform_non_affine (values ))
1300
+
1301
+ # Convert the result back to the shape of the input values.
1302
+ if ndim == 1 :
1303
+ return res .reshape (- 1 )
1304
+ elif ndim == 2 :
1305
+ return res
1306
+ else :
1307
+ raise ValueError (
1308
+ "Input values must have shape (N x {dims}) "
1309
+ "or ({dims})." .format (dims = self .input_dims ))
1310
+
1311
+ return res
1290
1312
1291
1313
def transform_affine (self , values ):
1292
1314
"""
@@ -1302,6 +1324,9 @@ def transform_affine(self, values):
1302
1324
1303
1325
Accepts a numpy array of shape (N x :attr:`input_dims`) and
1304
1326
returns a numpy array of shape (N x :attr:`output_dims`).
1327
+
1328
+ Alternatively, accepts a numpy array of length :a
8000
ttr:`input_dims`
1329
+ and returns a numpy array of length :attr:`output_dims`.
1305
1330
"""
1306
1331
return self .get_affine ().transform (values )
1307
1332
@@ -1318,6 +1343,9 @@ def transform_non_affine(self, values):
1318
1343
1319
1344
Accepts a numpy array of shape (N x :attr:`input_dims`) and
1320
1345
returns a numpy array of shape (N x :attr:`output_dims`).
1346
+
1347
+ Alternatively, accepts a numpy array of length :attr:`input_dims`
1348
+ and returns a numpy array of length :attr:`output_dims`.
1321
1349
"""
1322
1350
return values
1323
1351
@@ -2040,8 +2068,6 @@ def __repr__(self):
2040
2068
return "BlendedGenericTransform(%s,%s)" % (self ._x , self ._y )
2041
2069
2042
2070
def transform_non_affine (self , points ):
2043
- points = np .asanyarray (points ).reshape ((- 1 , 2 ))
2044
-
2045
2071
if self ._x .is_affine and self ._y .is_affine :
2046
2072
return points
2047
2073
x = self ._x
0 commit comments