@@ -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,60 +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
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
279
- sm.def (" overloaded3" , [](py::array_t <int >) { return " int" ; }, py::arg{}.noconvert ());
280
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
281
- sm.def (" overloaded3" , [](py::array_t <double >) { return " double" ; }, py::arg{}.noconvert ());
269
+ sm.def (
270
+ " overloaded3" , [](const py::array_t <int > &) { return " int" ; }, py::arg{}.noconvert ());
271
+ sm.def (
272
+ " overloaded3" ,
273
+ [](const py::array_t <double > &) { return " double" ; },
274
+ py::arg{}.noconvert ());
282
275
283
276
// Make sure we don't do unsafe coercion (e.g. float to int) when not using forcecast, but
284
277
// rather that float gets converted via the safe (conversion to double) overload:
285
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
286
- sm.def (" overloaded4" , [](py::array_t <long long , 0 >) { return " long long" ; });
287
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
288
- 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" ; });
289
280
290
281
// But we do allow conversion to int if forcecast is enabled (but only if no overload matches
291
282
// without conversion)
292
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
293
- sm.def (" overloaded5" , [](py::array_t <unsigned int >) { return " unsigned int" ; });
294
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
295
- 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" ; });
296
285
297
286
// test_greedy_string_overload
298
287
// Issue 685: ndarray shouldn't go to std::string overload
299
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
300
- sm.def (" issue685" , [](std::string) { return " string" ; });
301
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
302
- sm.def (" issue685" , [](py::array) { return " array" ; });
303
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
304
- 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" ; });
305
291
306
292
// test_array_unchecked_fixed_dims
307
293
sm.def (" proxy_add2" , [](py::array_t <double > a, double v) {
@@ -424,73 +410,53 @@ TEST_SUBMODULE(numpy_array, sm) {
424
410
425
411
// test_argument_conversions
426
412
sm.def (
427
- " accept_double" ,
428
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
429
- [](py::array_t <double , 0 >) {},
430
- py::arg (" a" ));
413
+ " accept_double" , [](const py::array_t <double , 0 > &) {}, py::arg (" a" ));
431
414
sm.def (
432
415
" accept_double_forcecast" ,
433
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
434
- [](py::array_t <double , py::array::forcecast>) {},
416
+ [](const py::array_t <double , py::array::forcecast> &) {},
435
417
py::arg (" a" ));
436
418
sm.def (
437
419
" accept_double_c_style" ,
438
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
439
- [](py::array_t <double , py::array::c_style>) {},
420
+ [](const py::array_t <double , py::array::c_style> &) {},
440
421
py::arg (" a" ));
441
422
sm.def (
442
423
" accept_double_c_style_forcecast" ,
443
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
444
- [](py::array_t <double , py::array::forcecast | py::array::c_style>) {},
424
+ [](const py::array_t <double , py::array::forcecast | py::array::c_style> &) {},
445
425
py::arg (" a" ));
446
426
sm.def (
447
427
" accept_double_f_style" ,
448
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
449
- [](py::array_t <double , py::array::f_style>) {},
428
+ [](const py::array_t <double , py::array::f_style> &) {},
450
429
py::arg (" a" ));
451
430
sm.def (
452
431
" accept_double_f_style_forcecast" ,
453
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
454
- [](py::array_t <double , py::array::forcecast | py::array::f_style>) {},
432
+ [](const py::array_t <double , py::array::forcecast | py::array::f_style> &) {},
455
433
py::arg (" a" ));
456
434
sm.def (
457
- " accept_double_noconvert" ,
458
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
459
- [](py::array_t <double , 0 >) {},
460
- " a" _a.noconvert ());
435
+ " accept_double_noconvert" , [](const py::array_t <double , 0 > &) {}, " a" _a.noconvert ());
461
436
sm.def (
462
437
" accept_double_forcecast_noconvert" ,
463
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
464
- [](py::array_t <double , py::array::forcecast>) {},
438
+ [](const py::array_t <double , py::array::forcecast> &) {},
465
439
" a" _a.noconvert ());
466
440
sm.def (
467
441
" accept_double_c_style_noconvert" ,
468
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
469
- [](py::array_t <double , py::array::c_style>) {},
442
+ [](const py::array_t <double , py::array::c_style> &) {},
470
443
" a" _a.noconvert ());
471
444
sm.def (
472
445
" accept_double_c_style_forcecast_noconvert" ,
473
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
474
- [](py::array_t <double , py::array::forcecast | py::array::c_style>) {},
446
+ [](const py::array_t <double , py::array::forcecast | py::array::c_style> &) {},
475
447
" a" _a.noconvert ());
476
448
sm.def (
477
449
" accept_double_f_style_noconvert" ,
478
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
479
- [](py::array_t <double , py::array::f_style>) {},
450
+ [](const py::array_t <double , py::array::f_style> &) {},
480
451
" a" _a.noconvert ());
481
452
sm.def (
482
453
" accept_double_f_style_forcecast_noconvert" ,
483
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
484
- [](py::array_t <double , py::array::forcecast | py::array::f_style>) {},
454
+ [](const py::array_t <double , py::array::forcecast | py::array::f_style> &) {},
485
455
" a" _a.noconvert ());
486
456
487
457
// Check that types returns correct npy format descriptor
488
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
489
- sm.def (" test_fmt_desc_float" , [](py::array_t <float >) {});
490
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
491
- sm.def (" test_fmt_desc_double" , [](py::array_t <double >) {});
492
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
493
- sm.def (" test_fmt_desc_const_float" , [](py::array_t <const float >) {});
494
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
495
- 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 > &) {});
496
462
}
0 commit comments