@@ -1285,8 +1285,30 @@ def transform(self, values):
12851285
12861286        Accepts a numpy array of shape (N x :attr:`input_dims`) and 
12871287        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`. 
12881291        """ 
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 
12901312
12911313    def  transform_affine (self , values ):
12921314        """ 
@@ -1302,6 +1324,9 @@ def transform_affine(self, values):
13021324
13031325        Accepts a numpy array of shape (N x :attr:`input_dims`) and 
13041326        returns a numpy array of shape (N x :attr:`output_dims`). 
1327+ 
1328+         Alternatively, accepts a numpy array of length :attr:`input_dims` 
1329+         and returns a numpy array of length :attr:`output_dims`. 
13051330        """ 
13061331        return  self .get_affine ().transform (values )
13071332
@@ -1318,6 +1343,9 @@ def transform_non_affine(self, values):
13181343
13191344        Accepts a numpy array of shape (N x :attr:`input_dims`) and 
13201345        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`. 
13211349        """ 
13221350        return  values 
13231351
@@ -2040,8 +2068,6 @@ def __repr__(self):
20402068        return  "BlendedGenericTransform(%s,%s)"  %  (self ._x , self ._y )
20412069
20422070    def  transform_non_affine (self , points ):
2043-         points  =  np .asanyarray (points ).reshape ((- 1 , 2 ))
2044- 
20452071        if  self ._x .is_affine  and  self ._y .is_affine :
20462072            return  points 
20472073        x  =  self ._x 
0 commit comments