Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 90c4852

Browse files
committed
Switch from py::arg to _a literals
1 parent 3ce5705 commit 90c4852

File tree

89 files changed

+457
-646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+457
-646
lines changed

python/src/adhesion/adhesion.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <ipc/adhesion/adhesion.hpp>
44

5-
namespace py = pybind11;
65
using namespace ipc;
76

87
void define_adhesion(py::module_& m)
@@ -21,7 +20,7 @@ void define_adhesion(py::module_& m)
2120
Returns:
2221
The normal adhesion potential.
2322
)ipc_Qu8mg5v7",
24-
py::arg("d"), py::arg("dhat_p"), py::arg("dhat_a"), py::arg("a2"));
23+
"d"_a, "dhat_p"_a, "dhat_a"_a, "a2"_a);
2524

2625
m.def(
2726
"normal_adhesion_potential_first_derivative",
@@ -38,7 +37,7 @@ void define_adhesion(py::module_& m)
3837
Returns:
3938
The first derivative of the normal adhesion potential wrt d.
4039
)ipc_Qu8mg5v7",
41-
py::arg("d"), py::arg("dhat_p"), py::arg("dhat_a"), py::arg("a2"));
40+
"d"_a, "dhat_p"_a, "dhat_a"_a, "a2"_a);
4241

4342
m.def(
4443
"normal_adhesion_potential_second_derivative",
@@ -55,7 +54,7 @@ void define_adhesion(py::module_& m)
5554
Returns:
5655
The second derivative of the normal adhesion potential wrt d.
5756
)ipc_Qu8mg5v7",
58-
py::arg("d"), py::arg("dhat_p"), py::arg("dhat_a"), py::arg("a2"));
57+
"d"_a, "dhat_p"_a, "dhat_a"_a, "a2"_a);
5958

6059
m.def(
6160
"max_normal_adhesion_force_magnitude",
@@ -71,7 +70,7 @@ void define_adhesion(py::module_& m)
7170
Returns:
7271
The maximum normal adhesion force magnitude.
7372
)ipc_Qu8mg5v7",
74-
py::arg("dhat_p"), py::arg("dhat_a"), py::arg("a2"));
73+
"dhat_p"_a, "dhat_a"_a, "a2"_a);
7574

7675
m.def(
7776
"tangential_adhesion_f0", &tangential_adhesion_f0,
@@ -85,7 +84,7 @@ void define_adhesion(py::module_& m)
8584
Returns:
8685
The tangential adhesion mollifier function at y.
8786
)ipc_Qu8mg5v7",
88-
py::arg("y"), py::arg("eps_a"));
87+
"y"_a, "eps_a"_a);
8988

9089
m.def(
9190
"tangential_adhesion_f1", &tangential_adhesion_f1,
@@ -99,7 +98,7 @@ void define_adhesion(py::module_& m)
9998
Returns:
10099
The first derivative of the tangential adhesion mollifier function at y.
101100
)ipc_Qu8mg5v7",
102-
py::arg("y"), py::arg("eps_a"));
101+
"y"_a, "eps_a"_a);
103102

104103
m.def(
105104
"tangential_adhesion_f2", &tangential_adhesion_f2,
@@ -113,7 +112,7 @@ void define_adhesion(py::module_& m)
113112
Returns:
114113
The second derivative of the tangential adhesion mollifier function at y.
115114
)ipc_Qu8mg5v7",
116-
py::arg("y"), py::arg("eps_a"));
115+
"y"_a, "eps_a"_a);
117116

118117
m.def(
119118
"tangential_adhesion_f1_over_x", &tangential_adhesion_f1_over_x,
@@ -127,7 +126,7 @@ void define_adhesion(py::module_& m)
127126
Returns:
128127
The first derivative of the tangential adhesion mollifier function divided by y.
129128
)ipc_Qu8mg5v7",
130-
py::arg("y"), py::arg("eps_a"));
129+
"y"_a, "eps_a"_a);
131130

132131
m.def(
133132
"tangential_adhesion_f2_x_minus_f1_over_x3",
@@ -142,5 +141,5 @@ void define_adhesion(py::module_& m)
142141
Returns:
143142
The second derivative of the tangential adhesion mollifier function times y minus the first derivative all divided by y cubed.
144143
)ipc_Qu8mg5v7",
145-
py::arg("y"), py::arg("eps_a"));
144+
"y"_a, "eps_a"_a);
146145
}

python/src/adhesion/bindings.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
#include <pybind11/pybind11.h>
44

5-
namespace py = pybind11;
6-
75
void define_adhesion(py::module_& m);

python/src/barrier/adaptive_stiffness.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <ipc/candidates/candidates.hpp>
55
#include <ipc/collisions/normal/normal_collisions.hpp>
66

7-
namespace py = pybind11;
87
using namespace ipc;
98

109
void define_adaptive_stiffness(py::module_& m)
@@ -42,10 +41,9 @@ void define_adaptive_stiffness(py::module_& m)
4241
The initial barrier stiffness.
4342
Maximum stiffness of the barrier.
4443
)ipc_Qu8mg5v7",
45-
py::arg("bbox_diagonal"), py::arg("barrier"), py::arg("dhat"),
46-
py::arg("average_mass"), py::arg("grad_energy"),
47-
py::arg("grad_barrier"), py::arg("min_barrier_stiffness_scale") = 1e11,
48-
py::arg("dmin") = 0);
44+
"bbox_diagonal"_a, "barrier"_a, "dhat"_a, "average_mass"_a,
45+
"grad_energy"_a, "grad_barrier"_a,
46+
"min_barrier_stiffness_scale"_a = 1e11, "dmin"_a = 0);
4947

5048
m.def(
5149
"update_barrier_stiffness", &update_barrier_stiffness,
@@ -64,10 +62,9 @@ void define_adaptive_stiffness(py::module_& m)
6462
Returns:
6563
The updated barrier stiffness.
6664
)ipc_Qu8mg5v7",
67-
py::arg("prev_min_distance"), py::arg("min_distance"),
68-
py::arg("max_barrier_stiffness"), py::arg("barrier_stiffness"),
69-
py::arg("bbox_diagonal"), py::arg("dhat_epsilon_scale") = 1e-9,
70-
py::arg("dmin") = 0);
65+
"prev_min_distance"_a, "min_distance"_a, "max_barrier_stiffness"_a,
66+
"barrier_stiffness"_a, "bbox_diagonal"_a, "dhat_epsilon_scale"_a = 1e-9,
67+
"dmin"_a = 0);
7168

7269
m.def(
7370
"semi_implicit_stiffness",
@@ -91,8 +88,7 @@ void define_adaptive_stiffness(py::module_& m)
9188
Returns:
9289
The semi-implicit stiffness.
9390
)ipc_Qu8mg5v7",
94-
py::arg("stencil"), py::arg("vertices"), py::arg("mass"),
95-
py::arg("local_hess"), py::arg("dmin"));
91+
"stencil"_a, "vertices"_a, "mass"_a, "local_hess"_a, "dmin"_a);
9692

9793
m.def(
9894
"semi_implicit_stiffness",
@@ -117,8 +113,8 @@ void define_adaptive_stiffness(py::module_& m)
117113
Returns:
118114
The semi-implicit stiffness's.
119115
)ipc_Qu8mg5v7",
120-
py::arg("mesh"), py::arg("vertices"), py::arg("collisions"),
121-
py::arg("vertex_masses"), py::arg("hess"), py::arg("dmin"));
116+
"mesh"_a, "vertices"_a, "collisions"_a, "vertex_masses"_a, "hess"_a,
117+
"dmin"_a);
122118

123119
m.def(
124120
"semi_implicit_stiffness",
@@ -143,6 +139,6 @@ void define_adaptive_stiffness(py::module_& m)
143139
Returns:
144140
The semi-implicit stiffness's.
145141
)ipc_Qu8mg5v7",
146-
py::arg("mesh"), py::arg("vertices"), py::arg("collisions"),
147-
py::arg("vertex_masses"), py::arg("hess"), py::arg("dmin"));
142+
"mesh"_a, "vertices"_a, "collisions"_a, "vertex_masses"_a, "hess"_a,
143+
"dmin"_a);
148144
}

python/src/barrier/barrier.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <ipc/barrier/barrier.hpp>
44

5-
namespace py = pybind11;
65
using namespace ipc;
76

87
class PyBarrier : public Barrier {
@@ -21,7 +20,7 @@ void define_barrier(py::module_& m)
2120
py::class_<Barrier, PyBarrier, std::shared_ptr<Barrier>>(m, "Barrier")
2221
.def(py::init<>())
2322
.def(
24-
"__call__", &Barrier::operator(), py::arg("d"), py::arg("dhat"),
23+
"__call__", &Barrier::operator(), "d"_a, "dhat"_a,
2524
R"ipc_Qu8mg5v7(
2625
Evaluate the barrier function.
2726
@@ -33,8 +32,7 @@ void define_barrier(py::module_& m)
3332
The value of the barrier function at d.
3433
)ipc_Qu8mg5v7")
3534
.def(
36-
"first_derivative", &Barrier::first_derivative, py::arg("d"),
37-
py::arg("dhat"),
35+
"first_derivative", &Barrier::first_derivative, "d"_a, "dhat"_a,
3836
R"ipc_Qu8mg5v7(
3937
Evaluate the first derivative of the barrier function wrt d.
4038
@@ -46,8 +44,7 @@ void define_barrier(py::module_& m)
4644
The value of the first derivative of the barrier function at d.
4745
)ipc_Qu8mg5v7")
4846
.def(
49-
"second_derivative", &Barrier::second_derivative, py::arg("d"),
50-
py::arg("dhat"),
47+
"second_derivative", &Barrier::second_derivative, "d"_a, "dhat"_a,
5148
R"ipc_Qu8mg5v7(
5249
Evaluate the second derivative of the barrier function wrt d.
5350
@@ -59,7 +56,7 @@ void define_barrier(py::module_& m)
5956
The value of the second derivative of the barrier function at d.
6057
)ipc_Qu8mg5v7")
6158
.def(
62-
"units", &Barrier::units, py::arg("dhat"),
59+
"units", &Barrier::units, "dhat"_a,
6360
R"ipc_Qu8mg5v7(
6461
Get the units of the barrier function.
6562
@@ -121,7 +118,8 @@ void define_barrier(py::module_& m)
121118
.def(py::init());
122119

123120
m.def(
124-
"barrier", &barrier,
121+
"barrier", &barrier, "d"_a,
122+
"dhat"_a
125123
R"ipc_Qu8mg5v7(
126124
Function that grows to infinity as d approaches 0 from the right.
127125
@@ -135,11 +133,10 @@ void define_barrier(py::module_& m)
135133
136134
Returns:
137135
The value of the barrier function at d.
138-
)ipc_Qu8mg5v7",
139-
py::arg("d"), py::arg("dhat"));
136+
)ipc_Qu8mg5v7");
140137

141138
m.def(
142-
"barrier_first_derivative", &barrier_first_derivative,
139+
"barrier_first_derivative", &barrier_first_derivative, "d"_a, "dhat"_a,
143140
R"ipc_Qu8mg5v7(
144141
Derivative of the barrier function.
145142
@@ -154,11 +151,11 @@ void define_barrier(py::module_& m)
154151
155152
Returns:
156153
The derivative of the barrier wrt d.
157-
)ipc_Qu8mg5v7",
158-
py::arg("d"), py::arg("dhat"));
154+
)ipc_Qu8mg5v7");
159155

160156
m.def(
161-
"barrier_second_derivative", &barrier_second_derivative,
157+
"barrier_second_derivative", &barrier_second_derivative, "d"_a,
158+
"dhat"_a,
162159
R"ipc_Qu8mg5v7(
163160
Second derivative of the barrier function.
164161
@@ -173,6 +170,5 @@ void define_barrier(py::module_& m)
173170
174171
Returns:
175172
The second derivative of the barrier wrt d.
176-
)ipc_Qu8mg5v7",
177-
py::arg("d"), py::arg("dhat"));
173+
)ipc_Qu8mg5v7");
178174
}

python/src/barrier/barrier_force_magnitude.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <ipc/barrier/barrier_force_magnitude.hpp>
44

5-
namespace py = pybind11;
65
using namespace ipc;
76

87
void define_barrier_force_magnitude(py::module_& m)
@@ -22,8 +21,8 @@ void define_barrier_force_magnitude(py::module_& m)
2221
Returns:
2322
The magnitude of the force.
2423
)ipc_Qu8mg5v7",
25-
py::arg("distance_squared"), py::arg("barrier"), py::arg("dhat"),
26-
py::arg("barrier_stiffness"), py::arg("dmin") = 0);
24+
"distance_squared"_a, "barrier"_a, "dhat"_a, "barrier_stiffness"_a,
25+
"dmin"_a = 0);
2726

2827
m.def(
2928
"barrier_force_magnitude_gradient", &barrier_force_magnitude_gradient,
@@ -41,7 +40,6 @@ void define_barrier_force_magnitude(py::module_& m)
4140
Returns:
4241
The gradient of the force.
4342
)ipc_Qu8mg5v7",
44-
py::arg("distance_squared"), py::arg("distance_squared_gradient"),
45-
py::arg("barrier"), py::arg("dhat"), py::arg("barrier_stiffness"),
46-
py::arg("dmin") = 0);
43+
"distance_squared"_a, "distance_squared_gradient"_a, "barrier"_a,
44+
"dhat"_a, "barrier_stiffness"_a, "dmin"_a = 0);
4745
}

python/src/barrier/bindings.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
#include <pybind11/pybind11.h>
44

5-
namespace py = pybind11;
6-
75
void define_adaptive_stiffness(py::module_& m);
86
void define_barrier_force_magnitude(py::module_& m);
97
void define_barrier(py::module_& m);

python/src/bindings.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include <common.hpp>
22
#include <bindings.hpp>
33

4-
namespace py = pybind11;
5-
64
PYBIND11_MODULE(ipctk, m)
75
{
86
// py::options options;

python/src/bindings.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@
1515

1616
#include <pybind11/pybind11.h>
1717

18-
namespace py = pybind11;
19-
2018
void define_collision_mesh(py::module_& m);
2119
void define_ipc(py::module_& m);

0 commit comments

Comments
 (0)