@@ -98,12 +98,13 @@ TEST_SUBMODULE(eigen, m) {
98
98
99
99
// test_eigen_ref_to_python
100
100
// Different ways of passing via Eigen::Ref; the first and second are the Eigen-recommended
101
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
102
- m. def ( " cholesky1 " , [](Eigen::Ref<MatrixXdR> x) -> Eigen::MatrixXd { return x.llt ().matrixL (); });
101
+ m. def ( " cholesky1 " ,
102
+ [](const Eigen::Ref<MatrixXdR> & x) -> Eigen::MatrixXd { return x.llt ().matrixL (); });
103
103
m.def (" cholesky2" , [](const Eigen::Ref<const MatrixXdR> &x) -> Eigen::MatrixXd { return x.llt ().matrixL (); });
104
104
m.def (" cholesky3" , [](const Eigen::Ref<MatrixXdR> &x) -> Eigen::MatrixXd { return x.llt ().matrixL (); });
105
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
106
- m.def (" cholesky4" , [](Eigen::Ref<const MatrixXdR> x) -> Eigen::MatrixXd { return x.llt ().matrixL (); });
105
+ m.def (" cholesky4" , [](const Eigen::Ref<const MatrixXdR> &x) -> Eigen::MatrixXd {
106
+ return x.llt ().matrixL ();
107
+ });
107
108
108
109
// test_eigen_ref_mutators
109
110
// Mutators: these add some value to the given element using Eigen, but Eigen should be mapping into
@@ -248,12 +249,9 @@ TEST_SUBMODULE(eigen, m) {
248
249
m.def (" fixed_copy_r" , [](const FixedMatrixR &m) -> FixedMatrixR { return m; });
249
250
m.def (" fixed_copy_c" , [](const FixedMatrixC &m) -> FixedMatrixC { return m; });
250
251
// test_mutator_descriptors
251
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
252
- m.def (" fixed_mutator_r" , [](Eigen::Ref<FixedMatrixR>) {});
253
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
254
- m.def (" fixed_mutator_c" , [](Eigen::Ref<FixedMatrixC>) {});
255
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
256
- m.def (" fixed_mutator_a" , [](py::EigenDRef<FixedMatrixC>) {});
252
+ m.def (" fixed_mutator_r" , [](const Eigen::Ref<FixedMatrixR> &) {});
253
+ m.def (" fixed_mutator_c" , [](const Eigen::Ref<FixedMatrixC> &) {});
254
+ m.def (" fixed_mutator_a" , [](const py::EigenDRef<FixedMatrixC> &) {});
257
255
// test_dense
258
256
m.def (" dense_r" , [mat]() -> DenseMatrixR { return DenseMatrixR (mat); });
259
257
m.def (" dense_c" , [mat]() -> DenseMatrixC { return DenseMatrixC (mat); });
@@ -284,9 +282,10 @@ TEST_SUBMODULE(eigen, m) {
284
282
// that would allow copying (if types or strides don't match) for comparison:
285
283
m.def (" get_elem" , &get_elem);
286
284
// Now this alternative that calls the tells pybind to fail rather than copy:
287
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
288
- m.def (" get_elem_nocopy" , [](Eigen::Ref<const Eigen::MatrixXd> m) -> double { return get_elem (m); },
289
- py::arg{}.noconvert ());
285
+ m.def (
286
+ " get_elem_nocopy" ,
287
+ [](const Eigen::Ref<const Eigen::MatrixXd> &m) -> double { return get_elem (m); },
288
+ py::arg{}.noconvert ());
290
289
// Also test a row-major-only no-copy const ref:
291
290
m.def (" get_elem_rm_nocopy" , [](Eigen::Ref<const Eigen::Matrix<long , -1 , -1 , Eigen::RowMajor>> &m) -> long { return m (2 , 1 ); },
292
291
py::arg{}.noconvert ());
@@ -301,20 +300,22 @@ TEST_SUBMODULE(eigen, m) {
301
300
// test_issue1105
302
301
// Issue #1105: when converting from a numpy two-dimensional (Nx1) or (1xN) value into a dense
303
302
// eigen Vector or RowVector, the argument would fail to load because the numpy copy would
304
- // fail: numpy won't broadcast a Nx1 into a 1-dimensional vector. NOLINTNEXTLINE
305
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
306
- m.def (" iss1105_col" , [](Eigen::VectorXd) { return true ; });
307
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
308
- m.def (" iss1105_row" , [](Eigen::RowVectorXd) { return true ; });
303
+ // fail: numpy won't broadcast a Nx1 into a 1-dimensional vector.
304
+ m.def (" iss1105_col" , [](const Eigen::VectorXd &) { return true ; });
305
+ m.def (" iss1105_row" , [](const Eigen::RowVectorXd &) { return true ; });
309
306
310
307
// test_named_arguments
311
308
// Make sure named arguments are working properly:
312
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
313
- m.def (" matrix_multiply" , [](const py::EigenDRef<const Eigen::MatrixXd> A, const py::EigenDRef<const Eigen::MatrixXd> B)
314
- -> Eigen::MatrixXd {
315
- if (A.cols () != B.rows ()) throw std::domain_error (" Nonconformable matrices!" );
316
- return A * B;
317
- }, py::arg (" A" ), py::arg (" B" ));
309
+ m.def (
310
+ " matrix_multiply" ,
311
+ [](const py::EigenDRef<const Eigen::MatrixXd> &A,
312
+ const py::EigenDRef<const Eigen::MatrixXd> &B) -> Eigen::MatrixXd {
313
+ if (A.cols () != B.rows ())
314
+ throw std::domain_error (" Nonconformable matrices!" );
315
+ return A * B;
316
+ },
317
+ py::arg (" A" ),
318
+ py::arg (" B" ));
318
319
319
320
// test_custom_operator_new
320
321
py::class_<CustomOperatorNew>(m, " CustomOperatorNew" )
@@ -326,8 +327,7 @@ TEST_SUBMODULE(eigen, m) {
326
327
// In case of a failure (the caster's temp array does not live long enough), creating
327
328
// a new array (np.ones(10)) increases the chances that the temp array will be garbage
328
329
// collected and/or that its memory will be overridden with different values.
329
- // NOLINTNEXTLINE (performance-unnecessary-value-param)
330
- m.def (" get_elem_direct" , [](Eigen::Ref<const Eigen::VectorXd> v) {
330
+ m.def (" get_elem_direct" , [](const Eigen::Ref<const Eigen::VectorXd> &v) {
331
331
py::module_::import (" numpy" ).attr (" ones" )(10 );
332
332
return v (5 );
333
333
});
0 commit comments