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):
287
287
288
288
def test_invalid_arguments (self ):
289
289
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 ):
294
291
t .transform (1 )
295
- with pytest .raises (RuntimeError ):
292
+ with pytest .raises (TypeError ):
296
293
t .transform ([[[1 ]]])
297
- with pytest .raises (RuntimeError ):
294
+ with pytest .raises (TypeError ):
298
295
t .transform ([])
299
- with pytest .raises (RuntimeError ):
296
+ with pytest .raises (TypeError ):
300
297
t .transform ([1 ])
301
- with pytest .raises (RuntimeError ):
298
+ with pytest .raises (TypeError ):
302
299
t .transform ([[1 ]])
303
- with pytest .raises (RuntimeError ):
300
+ with pytest .raises (TypeError ):
304
301
t .transform ([[1 , 2 , 3 ]])
305
302
306
303
def test_copy (self ):
Original file line number Diff line number Diff line change @@ -1880,9 +1880,14 @@ def to_values(self):
1880
1880
def transform_affine (self , values ):
1881
1881
mtx = self ._get_eigen_matrix ()
1882
1882
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
1886
1891
1887
1892
if DEBUG :
1888
1893
_transform_affine = transform_affine
Original file line number Diff line number Diff line change @@ -126,10 +126,8 @@ PYBIND11_MODULE(_eigen, m) {
126
126
}
127
127
)
128
128
.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;
133
131
}
134
132
)
135
133
You can’t perform that action at this time.
0 commit comments