Skip to content

Commit

Permalink
Fix stubgen warnings (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored May 18, 2024
1 parent 903e2ed commit ee9439d
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 19 deletions.
5 changes: 0 additions & 5 deletions cmake/fix_stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ def main():
with open(filename) as f:
content = f.read()

# Fix errors
content = content.replace(
"<ExpressionType.NONE: 0>", "ExpressionType.NONE"
).replace("<SolverExitCondition.SUCCESS: 0>", "SolverExitCondition.SUCCESS")

# Convert parameter names from camel case to snake case
new_content = ""
extract_location = 0
Expand Down
5 changes: 3 additions & 2 deletions cmake/modules/Pybind11Stubgen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ function(pybind11_stubgen target)
TARGET ${target}
POST_BUILD
COMMAND
${Python3_EXECUTABLE} -m pybind11_stubgen --ignore-all-errors
--print-invalid-expressions-as-is --exit-code
${Python3_EXECUTABLE} -m pybind11_stubgen --numpy-array-use-type-var
--ignore-unresolved-names
'numpy.float64|numpy.ndarray|scipy.sparse.csc_matrix' --exit-code
$<TARGET_FILE_BASE_NAME:${target}> -o
$<TARGET_FILE_DIR:${target}>-stubs
COMMAND
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/cpp/autodiff/BindGradient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace py = pybind11;
namespace sleipnir {

void BindGradient(py::class_<Gradient>& cls) {
using namespace pybind11::literals;
using namespace py::literals;

cls.def(py::init<Variable, Variable>(), "variable"_a, "wrt"_a,
DOC(sleipnir, Gradient, Gradient));
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/cpp/autodiff/BindHessian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace py = pybind11;
namespace sleipnir {

void BindHessian(py::class_<Hessian>& cls) {
using namespace pybind11::literals;
using namespace py::literals;

cls.def(py::init<Variable, VariableMatrix>(), "variable"_a, "wrt"_a,
DOC(sleipnir, Hessian, Hessian));
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/cpp/autodiff/BindJacobian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace py = pybind11;
namespace sleipnir {

void BindJacobian(py::class_<Jacobian>& cls) {
using namespace pybind11::literals;
using namespace py::literals;

cls.def(py::init<VariableMatrix, VariableMatrix>(), "variables"_a, "wrt"_a,
DOC(sleipnir, Jacobian, Jacobian));
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/cpp/autodiff/BindVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PYBIND11_WARNING_DISABLE_CLANG("-Wself-assign-overloaded")
namespace sleipnir {

void BindVariable(py::module_& autodiff, py::class_<Variable>& cls) {
using namespace pybind11::literals;
using namespace py::literals;

cls.def(py::init<>(), DOC(sleipnir, Variable, Variable));
cls.def(py::init<double>(), "value"_a, DOC(sleipnir, Variable, Variable, 2));
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/cpp/autodiff/BindVariableBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace sleipnir {

void BindVariableBlock(py::module_& autodiff,
py::class_<VariableBlock<VariableMatrix>>& cls) {
using namespace pybind11::literals;
using namespace py::literals;

// VariableBlock-VariableMatrix overloads
cls.def(py::self * VariableMatrix(), "rhs"_a);
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/cpp/autodiff/BindVariableMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace sleipnir {

void BindVariableMatrix(py::module_& autodiff,
py::class_<VariableMatrix>& cls) {
using namespace pybind11::literals;
using namespace py::literals;

cls.def(py::init<>(), DOC(sleipnir, VariableMatrix, VariableMatrix));
cls.def(py::init<int>(), "rows"_a,
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/cpp/optimization/BindOptimizationProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace py = pybind11;
namespace sleipnir {

void BindOptimizationProblem(py::class_<OptimizationProblem>& cls) {
using namespace pybind11::literals;
using namespace py::literals;

cls.def(py::init<>(),
DOC(sleipnir, OptimizationProblem, OptimizationProblem));
Expand Down
15 changes: 10 additions & 5 deletions jormungandr/cpp/optimization/BindSolverStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ namespace py = pybind11;
namespace sleipnir {

void BindSolverStatus(py::class_<SolverStatus>& cls) {
using namespace pybind11::literals;
using namespace py::literals;

cls.def(py::init<>());
cls.def(py::init<ExpressionType, ExpressionType, ExpressionType,
SolverExitCondition, double>(),
"cost_function_type"_a = ExpressionType::kNone,
"equality_constraint_type"_a = ExpressionType::kNone,
"inequality_constraint_type"_a = ExpressionType::kNone,
"exit_condition"_a = SolverExitCondition::kSuccess, "cost"_a = 0.0);
py::arg_v("cost_function_type", ExpressionType::kNone,
"ExpressionType.NONE"),
py::arg_v("equality_constraint_type", ExpressionType::kNone,
"ExpressionType.NONE"),
py::arg_v("inequality_constraint_type", ExpressionType::kNone,
"ExpressionType.NONE"),
py::arg_v("exit_condition", SolverExitCondition::kSuccess,
"SolverExitCondition.SUCCESS"),
"cost"_a = 0.0);
cls.def_readwrite("cost_function_type", &SolverStatus::costFunctionType,
DOC(sleipnir, SolverStatus, costFunctionType));
cls.def_readwrite("equality_constraint_type",
Expand Down

0 comments on commit ee9439d

Please sign in to comment.