Mantid
Loading...
Searching...
No Matches
CompositeFunction.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
10#include <boost/python/class.hpp>
11#include <boost/python/overloads.hpp>
12#include <boost/python/register_ptr_to_python.hpp>
13
16using namespace boost::python;
17
19
20namespace {
21
22using getParameterType1 = double (CompositeFunction::*)(size_t) const;
23using getParameterType2 = double (CompositeFunction::*)(const std::string &) const;
24
25using setParameterType2 = void (CompositeFunction::*)(const std::string &, const double &, bool);
26GNU_DIAG_OFF("unused-local-typedef")
27GNU_DIAG_OFF("conversion")
28
29BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(setParameterType2_Overloads, setParameter, 2, 3)
30GNU_DIAG_ON("conversion")
31GNU_DIAG_ON("unused-local-typedef")
32} // namespace
33
35
36 register_ptr_to_python<std::shared_ptr<CompositeFunction>>();
37
38 class_<CompositeFunction, bases<IFunction>, boost::noncopyable>("CompositeFunction", "Composite Fit functions")
39 .def("nFunctions", &CompositeFunction::nFunctions, arg("self"), "Get the number of member functions.")
40 .def("__len__", &CompositeFunction::nFunctions, arg("self"), "Get the number of member functions.")
41 .def("getFunction", &CompositeFunction::getFunction, (arg("self"), arg("i")), "Get the i-th function.")
42 .def("__getitem__", &CompositeFunction::getFunction, (arg("self"), arg("i")), "Get the i-th function.")
43 .def("__setitem__", &CompositeFunction::replaceFunction, (arg("self"), arg("i"), arg("f")),
44 "Put function in place of the i-th function.")
45 .def("add", &CompositeFunction::addFunction, (arg("self"), arg("function")), "Add a member function.")
46 .def("getParameterValue", (getParameterType1)&CompositeFunction::getParameter, (arg("self"), arg("i")),
47 "Get value of parameter of given index.")
48 .def("getParameterValue", (getParameterType2)&CompositeFunction::getParameter, (arg("self"), arg("name")),
49 "Get value of parameter of given name.")
50 .def("__getitem__", (getParameterType2)&CompositeFunction::getParameter, (arg("self"), arg("name")),
51 "Get value of parameter of given name.")
52 .def("__setitem__", (setParameterType2)&CompositeFunction::setParameter,
53 setParameterType2_Overloads((arg("self"), arg("name"), arg("value"), arg("explicitlySet")),
54 "Get value of parameter of given name."))
55 .def("__delitem__", &CompositeFunction::removeFunction, (arg("self"), arg("index")));
56}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
void export_CompositeFunction()
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader, valueAsPrettyStr, 0, 2) void export_Property()
Definition: Property.cpp:102
#define GNU_DIAG_ON(x)
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
A composite function is a function containing other functions.
virtual size_t addFunction(IFunction_sptr f)
Add a function at the back of the internal function list.
void setParameter(size_t, const double &value, bool explicitlySet=true) override
Set i-th parameter.
std::size_t nFunctions() const override
Number of functions.
void replaceFunction(size_t functionIndex, const IFunction_sptr &f)
Replace a function.
double getParameter(size_t i) const override
Get i-th parameter.
void removeFunction(size_t i)
Remove a function.
IFunction_sptr getFunction(std::size_t i) const override
Returns the pointer to i-th function.
This is an interface to a fitting function - a semi-abstarct class.
Definition: IFunction.h:163