GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/activations/smooth-2norm.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 13 13 100.0%
Branches: 9 18 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
10 #include "crocoddyl/core/activations/smooth-2norm.hpp"
11
12 #include "python/crocoddyl/core/activation-base.hpp"
13 #include "python/crocoddyl/core/core.hpp"
14 #include "python/crocoddyl/utils/copyable.hpp"
15
16 namespace crocoddyl {
17 namespace python {
18
19 10 void exposeActivationSmooth2Norm() {
20 boost::python::register_ptr_to_python<
21 10 boost::shared_ptr<ActivationModelSmooth2Norm> >();
22
23
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ActivationModelSmooth2Norm, bp::bases<ActivationModelAbstract> >(
24 "ActivationModelSmooth2Norm",
25 "Smooth-2Norm activation model.\n\n"
26 "It describes a smooth representation of a 2-norm, i.e.\n"
27 "sqrt{eps + sum^nr_{i=0} ||ri||^2}, where ri is the scalar residual for "
28 "the i constraints,\n."
29 "and nr is the dimension of the residual vector.",
30
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<std::size_t, bp::optional<double> >(
31 20 bp::args("self", "nr", "eps"),
32 "Initialize the activation model.\n\n"
33 ":param nr: dimension of the residual vector\n"
34 ":param eps: smoothing factor (default: 1.)"))
35
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("calc", &ActivationModelSmooth2Norm::calc,
36
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "r"),
37 "Compute the smooth-2norm function.\n\n"
38 ":param data: activation data\n"
39 ":param r: residual vector")
40
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("calcDiff", &ActivationModelSmooth2Norm::calcDiff,
41
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "r"),
42 "Compute the derivatives of a smooth-2norm function.\n\n"
43 "It assumes that calc has been run first.\n"
44 ":param data: activation data\n"
45 ":param r: residual vector \n")
46
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("createData", &ActivationModelSmooth2Norm::createData,
47
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self"), "Create the smooth-2norm activation data.\n\n")
48
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ActivationModelSmooth2Norm>());
49 10 }
50
51 } // namespace python
52 } // namespace crocoddyl
53