File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -287,20 +287,17 @@ def test_translate_plus_other(self):
287287
288288 def test_invalid_arguments (self ):
289289 t = mtransforms .Affine2D ()
290- # The wrong number of dimensions and a wrong shape with a possible number of
291- # dimensions are both caught by pybind11, which always raises the less precise
292- # RuntimeError.
293- with pytest .raises (RuntimeError ):
290+ with pytest .raises (TypeError ):
294291 t .transform (1 )
295- with pytest .raises (RuntimeError ):
292+ with pytest .raises (TypeError ):
296293 t .transform ([[[1 ]]])
297- with pytest .raises (RuntimeError ):
294+ with pytest .raises (TypeError ):
298295 t .transform ([])
299- with pytest .raises (RuntimeError ):
296+ with pytest .raises (TypeError ):
300297 t .transform ([1 ])
301- with pytest .raises (RuntimeError ):
298+ with pytest .raises (TypeError ):
302299 t .transform ([[1 ]])
303- with pytest .raises (RuntimeError ):
300+ with pytest .raises (TypeError ):
304301 t .transform ([[1 , 2 , 3 ]])
305302
306303 def test_copy (self ):
Original file line number Diff line number Diff line change @@ -1880,9 +1880,14 @@ def to_values(self):
18801880 def transform_affine (self , values ):
18811881 mtx = self ._get_eigen_matrix ()
18821882 if isinstance (values , np .ma .MaskedArray ):
1883- tpoints = mtx .affine_transform (values .data )
1884- return np .ma .MaskedArray (tpoints , mask = np .ma .getmask (values ))
1885- return mtx .affine_transform (values )
1883+ tpoints = mtx .affine_transform (values .data .T ).T
1884+ result = np .ma .MaskedArray (tpoints , mask = np .ma .getmask (values ))
1885+ else :
1886+ values = np .asarray (values )
1887+ result = mtx .affine_transform (values .T ).T
1888+ if len (values .shape ) == 2 :
1889+ result = np .atleast_2d (result )
1890+ return result
18861891
18871892 if DEBUG :
18881893 _transform_affine = transform_affine
Original file line number Diff line number Diff line change @@ -126,10 +126,8 @@ PYBIND11_MODULE(_eigen, m) {
126126 }
127127 )
128128 .def (" affine_transform" ,
129- [](const Eigen::Affine2d& self, py::array_t <double > vertices_arr) {
130- auto vertices = vertices_arr.attr (" transpose" )().cast <Eigen::Ref<const Eigen::Matrix2Xd>>();
131- auto result = py::cast (self * vertices, py::return_value_policy::move);
132- return result.attr (" transpose" )();
129+ [](const Eigen::Affine2d& self, Eigen::Ref<const Eigen::Matrix2Xd> vertices) {
130+ return self * vertices;
133131 }
134132 )
135133
You can’t perform that action at this time.
0 commit comments