@@ -226,8 +226,7 @@ TEST_SUBMODULE(numpy_array, sm) {
226
226
return py::isinstance<py::array>(std::move (yes))
227
227
&& !py::isinstance<py::array>(std::move (no));
228
228
});
229
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
230
- sm.def (" isinstance_typed" , [](py::object o) {
229
+ sm.def (" isinstance_typed" , [](const py::object &o) {
231
230
return py::isinstance<py::array_t <double >>(o) && !py::isinstance<py::array_t <int >>(o);
232
231
});
233
232
@@ -248,66 +247,47 @@ TEST_SUBMODULE(numpy_array, sm) {
248
247
});
249
248
250
249
// test_overload_resolution
251
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
252
- sm.def (" overloaded" , [](py::array_t <double >) { return " double" ; });
253
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
254
- sm.def (" overloaded" , [](py::array_t <float >) { return " float" ; });
255
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
256
- sm.def (" overloaded" , [](py::array_t <int >) { return " int" ; });
257
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
258
- sm.def (" overloaded" , [](py::array_t <unsigned short >) { return " unsigned short" ; });
259
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
260
- sm.def (" overloaded" , [](py::array_t <long long >) { return " long long" ; });
261
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
262
- sm.def (" overloaded" , [](py::array_t <std::complex<double >>) { return " double complex" ; });
263
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
264
- sm.def (" overloaded" , [](py::array_t <std::complex<float >>) { return " float complex" ; });
265
-
266
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
267
- sm.def (" overloaded2" , [](py::array_t <std::complex<double >>) { return " double complex" ; });
268
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
269
- sm.def (" overloaded2" , [](py::array_t <double >) { return " double" ; });
270
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
271
- sm.def (" overloaded2" , [](py::array_t <std::complex<float >>) { return " float complex" ; });
272
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
273
- sm.def (" overloaded2" , [](py::array_t <float >) { return " float" ; });
250
+ sm.def (" overloaded" , [](const py::array_t <double > &) { return " double" ; });
251
+ sm.def (" overloaded" , [](const py::array_t <float > &) { return " float" ; });
252
+ sm.def (" overloaded" , [](const py::array_t <int > &) { return " int" ; });
253
+ sm.def (" overloaded" , [](const py::array_t <unsigned short > &) { return " unsigned short" ; });
254
+ sm.def (" overloaded" , [](const py::array_t <long long > &) { return " long long" ; });
255
+ sm.def (" overloaded" ,
256
+ [](const py::array_t <std::complex<double >> &) { return " double complex" ; });
257
+ sm.def (" overloaded" , [](const py::array_t <std::complex<float >> &) { return " float complex" ; });
258
+
259
+ sm.def (" overloaded2" ,
260
+ [](const py::array_t <std::complex<double >> &) { return " double complex" ; });
261
+ sm.def (" overloaded2" , [](const py::array_t <double > &) { return " double" ; });
262
+ sm.def (" overloaded2" ,
263
+ [](const py::array_t <std::complex<float >> &) { return " float complex" ; });
264
+ sm.def (" overloaded2" , [](const py::array_t <float > &) { return " float" ; });
274
265
275
266
// [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works.
276
267
277
268
// Only accept the exact types:
278
269
sm.def (
279
- " overloaded3" ,
280
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
281
- [](py::array_t <int >) { return " int" ; },
282
- py::arg{}.noconvert ());
270
+ " overloaded3" , [](const py::array_t <int > &) { return " int" ; }, py::arg{}.noconvert ());
283
271
sm.def (
284
272
" overloaded3" ,
285
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
286
- [](py::array_t <double >) { return " double" ; },
273
+ [](const py::array_t <double > &) { return " double" ; },
287
274
py::arg{}.noconvert ());
288
275
289
276
// Make sure we don't do unsafe coercion (e.g. float to int) when not using forcecast, but
290
277
// rather that float gets converted via the safe (conversion to double) overload:
291
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
292
- sm.def (" overloaded4" , [](py::array_t <long long , 0 >) { return " long long" ; });
293
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
294
- sm.def (" overloaded4" , [](py::array_t <double , 0 >) { return " double" ; });
278
+ sm.def (" overloaded4" , [](const py::array_t <long long , 0 > &) { return " long long" ; });
279
+ sm.def (" overloaded4" , [](const py::array_t <double , 0 > &) { return " double" ; });
295
280
296
281
// But we do allow conversion to int if forcecast is enabled (but only if no overload matches
297
282
// without conversion)
298
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
299
- sm.def (" overloaded5" , [](py::array_t <unsigned int >) { return " unsigned int" ; });
300
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
301
- sm.def (" overloaded5" , [](py::array_t <double >) { return " double" ; });
283
+ sm.def (" overloaded5" , [](const py::array_t <unsigned int > &) { return " unsigned int" ; });
284
+ sm.def (" overloaded5" , [](const py::array_t <double > &) { return " double" ; });
302
285
303
286
// test_greedy_string_overload
304
287
// Issue 685: ndarray shouldn't go to std::string overload
305
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
306
- sm.def (" issue685" , [](std::string) { return " string" ; });
307
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
308
- sm.def (" issue685" , [](py::array) { return " array" ; });
309
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
310
- sm.def (" issue685" , [](py::object) { return " other" ; });
288
+ sm.def (" issue685" , [](const std::string &) { return " string" ; });
289
+ sm.def (" issue685" , [](const py::array &) { return " array" ; });
290
+ sm.def (" issue685" , [](const py::object &) { return " other" ; });
311
291
312
292
// test_array_unchecked_fixed_dims
313
293
sm.def (" proxy_add2" , [](py::array_t <double > a, double v) {
@@ -430,73 +410,53 @@ TEST_SUBMODULE(numpy_array, sm) {
430
410
431
411
// test_argument_conversions
432
412
sm.def (
433
- " accept_double" ,
434
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
435
- [](py::array_t <double , 0 >) {},
436
- py::arg (" a" ));
413
+ " accept_double" , [](const py::array_t <double , 0 > &) {}, py::arg (" a" ));
437
414
sm.def (
438
415
" accept_double_forcecast" ,
439
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
440
- [](py::array_t <double , py::array::forcecast>) {},
416
+ [](const py::array_t <double , py::array::forcecast> &) {},
441
417
py::arg (" a" ));
442
418
sm.def (
443
419
" accept_double_c_style" ,
444
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
445
- [](py::array_t <double , py::array::c_style>) {},
420
+ [](const py::array_t <double , py::array::c_style> &) {},
446
421
py::arg (" a" ));
447
422
sm.def (
448
423
" accept_double_c_style_forcecast" ,
449
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
450
- [](py::array_t <double , py::array::forcecast | py::array::c_style>) {},
424
+ [](const py::array_t <double , py::array::forcecast | py::array::c_style> &) {},
451
425
py::arg (" a" ));
452
426
sm.def (
453
427
" accept_double_f_style" ,
454
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
455
- [](py::array_t <double , py::array::f_style>) {},
428
+ [](const py::array_t <double , py::array::f_style> &) {},
456
429
py::arg (" a" ));
457
430
sm.def (
458
431
" accept_double_f_style_forcecast" ,
459
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
460
- [](py::array_t <double , py::array::forcecast | py::array::f_style>) {},
432
+ [](const py::array_t <double , py::array::forcecast | py::array::f_style> &) {},
461
433
py::arg (" a" ));
462
434
sm.def (
463
- " accept_double_noconvert" ,
464
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
465
- [](py::array_t <double , 0 >) {},
466
- " a" _a.noconvert ());
435
+ " accept_double_noconvert" , [](const py::array_t <double , 0 > &) {}, " a" _a.noconvert ());
467
436
sm.def (
468
437
" accept_double_forcecast_noconvert" ,
469
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
470
- [](py::array_t <double , py::array::forcecast>) {},
438
+ [](const py::array_t <double , py::array::forcecast> &) {},
471
439
" a" _a.noconvert ());
472
440
sm.def (
473
441
" accept_double_c_style_noconvert" ,
474
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
475
- [](py::array_t <double , py::array::c_style>) {},
442
+ [](const py::array_t <double , py::array::c_style> &) {},
476
443
" a" _a.noconvert ());
477
444
sm.def (
478
445
" accept_double_c_style_forcecast_noconvert" ,
479
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
480
- [](py::array_t <double , py::array::forcecast | py::array::c_style>) {},
446
+ [](const py::array_t <double , py::array::forcecast | py::array::c_style> &) {},
481
447
" a" _a.noconvert ());
482
448
sm.def (
483
449
" accept_double_f_style_noconvert" ,
484
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
485
- [](py::array_t <double , py::array::f_style>) {},
450
+ [](const py::array_t <double , py::array::f_style> &) {},
486
451
" a" _a.noconvert ());
487
452
sm.def (
488
453
" accept_double_f_style_forcecast_noconvert" ,
489
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
490
- [](py::array_t <double , py::array::forcecast | py::array::f_style>) {},
454
+ [](const py::array_t <double , py::array::forcecast | py::array::f_style> &) {},
491
455
" a" _a.noconvert ());
492
456
493
457
// Check that types returns correct npy format descriptor
494
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
495
- sm.def (" test_fmt_desc_float" , [](py::array_t <float >) {});
496
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
497
- sm.def (" test_fmt_desc_double" , [](py::array_t <double >) {});
498
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
499
- sm.def (" test_fmt_desc_const_float" , [](py::array_t <const float >) {});
500
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
501
- sm.def (" test_fmt_desc_const_double" , [](py::array_t <const double >) {});
458
+ sm.def (" test_fmt_desc_float" , [](const py::array_t <float > &) {});
459
+ sm.def (" test_fmt_desc_double" , [](const py::array_t <double > &) {});
460
+ sm.def (" test_fmt_desc_const_float" , [](const py::array_t <const float > &) {});
461
+ sm.def (" test_fmt_desc_const_double" , [](const py::array_t <const double > &) {});
502
462
}
0 commit comments