Skip to content

Commit b753608

Browse files
committed
tests: add notes about intel, cleanup
1 parent 20e467d commit b753608

7 files changed

+24
-15
lines changed

tests/test_builtin_casters.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ TEST_SUBMODULE(builtin_casters, m) {
183183
m.def("load_nullptr_t", [](std::nullptr_t) {}); // not useful, but it should still compile
184184
m.def("cast_nullptr_t", []() { return std::nullptr_t{}; });
185185

186+
// [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works.
187+
186188
// test_bool_caster
187189
m.def("bool_passthrough", [](bool arg) { return arg; });
188190
m.def("bool_passthrough_noconvert", [](bool arg) { return arg; }, py::arg{}.noconvert());

tests/test_callbacks.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ TEST_SUBMODULE(callbacks, m) {
119119

120120
class AbstractBase {
121121
public:
122-
// ICC can't handle this being defaulted
123-
virtual ~AbstractBase() {}; // NOLINT
122+
// [workaround(intel)] = default does not work here
123+
virtual ~AbstractBase() {}; // NOLINT(modernize-use-equals-default)
124124
virtual unsigned int func() = 0;
125125
};
126126
m.def("func_accepting_func_accepting_base", [](std::function<double(AbstractBase&)>) { });

tests/test_class.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ TEST_SUBMODULE(class_, m) {
323323

324324
class PublicistB : public ProtectedB {
325325
public:
326-
~PublicistB() override {}; // NOLINT(modernize-use-equals-default) breaks ICPC
326+
// [workaround(intel)] = default does not work here
327+
~PublicistB() override {}; // NOLINT(modernize-use-equals-default)
327328
using ProtectedB::foo;
328329
};
329330

tests/test_custom_type_casters.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ TEST_SUBMODULE(custom_type_casters, m) {
9999
}
100100
static ArgInspector2 h(ArgInspector2 a, ArgAlwaysConverts) { return a; }
101101
};
102+
// [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works.
102103
py::class_<ArgInspector>(m, "ArgInspector")
103104
.def(py::init<>())
104105
.def("f", &ArgInspector::f, py::arg(), py::arg() = ArgAlwaysConverts())
@@ -108,10 +109,10 @@ TEST_SUBMODULE(custom_type_casters, m) {
108109
m.def("arg_inspect_func", [](ArgInspector2 a, ArgInspector1 b, ArgAlwaysConverts) { return a.arg + "\n" + b.arg; },
109110
py::arg{}.noconvert(false), py::arg_v(nullptr, ArgInspector1()).noconvert(true), py::arg() = ArgAlwaysConverts());
110111

111-
m.def("floats_preferred", [](double f) { return 0.5 * f; }, py::arg("f"));
112-
m.def("floats_only", [](double f) { return 0.5 * f; }, py::arg{"f"}.noconvert());
113-
m.def("ints_preferred", [](int i) { return i / 2; }, py::arg("i"));
114-
m.def("ints_only", [](int i) { return i / 2; }, py::arg{"i"}.noconvert());
112+
m.def("floats_preferred", [](double f) { return 0.5 * f; }, "f"_a);
113+
m.def("floats_only", [](double f) { return 0.5 * f; }, "f"_a.noconvert());
114+
m.def("ints_preferred", [](int i) { return i / 2; }, "i"_a);
115+
m.def("ints_only", [](int i) { return i / 2; }, "i"_a.noconvert());
115116

116117
// test_custom_caster_destruction
117118
// Test that `take_ownership` works on types with a custom type caster when given a pointer

tests/test_eigen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ TEST_SUBMODULE(eigen, m) {
273273
m.def("cpp_ref_r", [](py::handle m) { return m.cast<Eigen::Ref<MatrixXdR>>()(1, 0); });
274274
m.def("cpp_ref_any", [](py::handle m) { return m.cast<py::EigenDRef<Eigen::MatrixXd>>()(1, 0); });
275275

276+
// [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works.
276277

277278
// test_nocopy_wrapper
278279
// Test that we can prevent copying into an argument that would normally copy: First a version

tests/test_methods_and_attributes.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ TEST_SUBMODULE(methods_and_attributes, m) {
322322
m.def("should_fail", [](int, UnregisteredType) {}, py::arg(), py::arg() = UnregisteredType());
323323
});
324324

325+
// [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works.
326+
325327
// test_accepts_none
326328
py::class_<NoneTester, std::shared_ptr<NoneTester>>(m, "NoneTester")
327329
.def(py::init<>());
@@ -336,8 +338,8 @@ TEST_SUBMODULE(methods_and_attributes, m) {
336338
m.def("ok_none4", &none4, py::arg{}.none(true));
337339
m.def("ok_none5", &none5);
338340

339-
m.def("no_none_kwarg", &none2, py::arg{"a"}.none(false));
340-
m.def("no_none_kwarg_kw_only", &none2, py::kw_only(), py::arg{"a"}.none(false));
341+
m.def("no_none_kwarg", &none2, "a"_a.none(false));
342+
m.def("no_none_kwarg_kw_only", &none2, py::kw_only(), "a"_a.none(false));
341343

342344
// test_str_issue
343345
// Issue #283: __str__ called on uninitialized instance when constructor arguments invalid

tests/test_numpy_array.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ TEST_SUBMODULE(numpy_array, sm) {
258258
sm.def("overloaded2", [](py::array_t<std::complex<float>>) { return "float complex"; });
259259
sm.def("overloaded2", [](py::array_t<float>) { return "float"; });
260260

261+
// [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works.
262+
261263
// Only accept the exact types:
262264
sm.def("overloaded3", [](py::array_t<int>) { return "int"; }, py::arg{}.noconvert());
263265
sm.def("overloaded3", [](py::array_t<double>) { return "double"; }, py::arg{}.noconvert());
@@ -419,20 +421,20 @@ TEST_SUBMODULE(numpy_array, sm) {
419421
py::arg("a"));
420422
sm.def("accept_double_noconvert",
421423
[](py::array_t<double, 0>) {},
422-
py::arg{"a"}.noconvert());
424+
"a"_a.noconvert());
423425
sm.def("accept_double_forcecast_noconvert",
424426
[](py::array_t<double, py::array::forcecast>) {},
425-
py::arg{"a"}.noconvert());
427+
"a"_a.noconvert());
426428
sm.def("accept_double_c_style_noconvert",
427429
[](py::array_t<double, py::array::c_style>) {},
428-
py::arg{"a"}.noconvert());
430+
"a"_a.noconvert());
429431
sm.def("accept_double_c_style_forcecast_noconvert",
430432
[](py::array_t<double, py::array::forcecast | py::array::c_style>) {},
431-
py::arg{"a"}.noconvert());
433+
"a"_a.noconvert());
432434
sm.def("accept_double_f_style_noconvert",
433435
[](py::array_t<double, py::array::f_style>) {},
434-
py::arg{"a"}.noconvert());
436+
"a"_a.noconvert());
435437
sm.def("accept_double_f_style_forcecast_noconvert",
436438
[](py::array_t<double, py::array::forcecast | py::array::f_style>) {},
437-
py::arg{"a"}.noconvert());
439+
"a"_a.noconvert());
438440
}

0 commit comments

Comments
 (0)