GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/utils/callbacks.cpp
Date: 2025-01-30 11:01:55
Exec Total Coverage
Lines: 16 16 100.0%
Branches: 12 24 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh,
5 // University of Oxford, Heriot-Watt University
6 // Copyright note valid unless otherwise stated in individual files.
7 // All rights reserved.
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #include "crocoddyl/core/utils/callbacks.hpp"
11
12 #include "python/crocoddyl/core/core.hpp"
13 #include "python/crocoddyl/utils/copyable.hpp"
14
15 namespace crocoddyl {
16 namespace python {
17
18 10 void exposeCallbacks() {
19 10 bp::register_ptr_to_python<std::shared_ptr<CallbackAbstract> >();
20
21 20 bp::enum_<VerboseLevel>("VerboseLevel")
22
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .value("_0", _0)
23
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .value("_1", _1)
24
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .value("_2", _2)
25
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .value("_3", _3)
26
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .value("_4", _4);
27
28
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<CallbackVerbose, bp::bases<CallbackAbstract> >(
29 "CallbackVerbose", "Callback function for printing the solver values.",
30
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<bp::optional<VerboseLevel, std::size_t> >(
31 20 bp::args("self", "level", "precision"),
32 "Initialize the differential verbose callback.\n\n"
33 ":param level: verbose level (default _4)\n"
34 ":param precision: precision of floating point output (default 5)"))
35
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 .def("__call__", &CallbackVerbose::operator(), bp::args("self", "solver"),
36 "Run the callback function given a solver.\n\n"
37 ":param solver: solver to be diagnostic")
38
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("level", &CallbackVerbose::get_level,
39 &CallbackVerbose::set_level, "verbose level")
40
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("precision", &CallbackVerbose::get_precision,
41 &CallbackVerbose::set_precision, "precision")
42
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<CallbackVerbose>());
43 10 }
44
45 } // namespace python
46 } // namespace crocoddyl
47