GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/activations/quadratic-flat-log.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) 2020-2024, LAAS-CNRS, University of Edinburgh
5 // Heriot-Watt University
6 // Copyright note valid unless otherwise stated in individual files.
7 // All rights reserved.
8 ///////////////////////////////////////////////////////////////////////////////
9 #include "crocoddyl/core/activations/quadratic-flat-log.hpp"
10
11 #include "python/crocoddyl/core/activation-base.hpp"
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 exposeActivationQuadFlatLog() {
19 boost::python::register_ptr_to_python<
20 10 std::shared_ptr<ActivationModelQuadFlatLog> >();
21
22
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ActivationModelQuadFlatLog, bp::bases<ActivationModelAbstract> >(
23 "ActivationModelQuadFlatLog",
24 "Quadratic flat activation model.\n"
25 "A quadratic flat action describes a quadratic flat function that "
26 "depends on the residual, i.e.\n"
27 "log(1 + ||r||^2 / alpha).",
28
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<std::size_t, double>(
29 20 bp::args("self", "nr", "alpha"),
30 "Initialize the activation model.\n\n"
31 ":param nr: dimension of the cost-residual vector"
32 "param alpha: width of quadratic basin near zero"))
33
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("calc", &ActivationModelQuadFlatLog::calc,
34
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "r"),
35 "Compute the log(1 + ||r||^2 / alpha).\n"
36 ":param data: activation data\n"
37 ":param r: residual vector")
38
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("calcDiff", &ActivationModelQuadFlatLog::calcDiff,
39
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "r"),
40 "Compute the derivatives of a quadratic flat function.\n"
41 "Note that the Hessian is constant, so we don't write again this "
42 "value.\n"
43 ":param data: activation data\n"
44 ":param r: residual vector \n")
45
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("createData", &ActivationModelQuadFlatLog::createData,
46
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self"), "Create the quadratic flat activation data.\n")
47
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
48
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 "alpha", bp::make_function(&ActivationModelQuadFlatLog::get_alpha),
49
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_function(&ActivationModelQuadFlatLog::set_alpha), "alpha")
50
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ActivationModelQuadFlatLog>());
51 10 }
52
53 } // namespace python
54 } // namespace crocoddyl
55