24 #include "pybind11/pybind11.h" 26 #include "ndarray/pybind11.h" 43 using PyPrior = py::class_<Prior, std::shared_ptr<Prior>>;
44 PyPrior
cls(mod,
"Prior");
45 cls.def(
"getTag", &Prior::getTag);
46 cls.def(
"evaluate", &Prior::evaluate,
"nonlinear"_a,
"amplitudes"_a);
47 cls.def(
"evaluateDerivatives", &Prior::evaluateDerivatives,
"nonlinear"_a,
"amplitudes"_a,
48 "nonlinearGradient"_a,
"amplitudeGradient"_a,
"nonlinearHessian"_a,
"amplitudeHessian"_a,
50 cls.def(
"marginalize", &Prior::marginalize,
"gradient"_a,
"hessian"_a,
"nonlinear"_a);
51 cls.def(
"maximize", &Prior::maximize,
"gradient"_a,
"hessian"_a,
"nonlinear"_a,
"amplitudes"_a);
52 cls.def(
"drawAmplitudes", &Prior::drawAmplitudes,
"gradient"_a,
"hessian"_a,
"nonlinear"_a,
"rng"_a,
53 "amplitudes"_a,
"weights"_a,
"multiplyWeights"_a =
false);
56 static void declareMixturePrior(
py::module &mod) {
57 using Class = MixturePrior;
58 using PyClass = py::class_<Class, std::shared_ptr<Class>, Prior>;
59 PyClass
cls(mod,
"MixturePrior");
61 cls.def_static(
"getUpdateRestriction", &Class::getUpdateRestriction,
62 py::return_value_policy::reference);
63 cls.def(
"getMixture", &Class::getMixture);
67 static void declareSemiEmpiricalPrior(
py::module &mod) {
68 using Class = SemiEmpiricalPrior;
69 using Control = SemiEmpiricalPriorControl;
70 using PyControl = py::class_<Control, std::shared_ptr<Control>>;
71 using PyClass = py::class_<Class, std::shared_ptr<Class>, Prior>;
73 PyControl clsControl(mod,
"SemiEmpiricalPriorControl");
74 clsControl.def(py::init<>());
84 PyClass
cls(mod,
"SemiEmpiricalPrior");
85 cls.def(py::init<Control>(),
"ctrl"_a);
86 cls.attr(
"Control") = clsControl;
90 static void declareSoftenedLinearPrior(
py::module &mod) {
91 using Class = SoftenedLinearPrior;
92 using Control = SoftenedLinearPriorControl;
93 using PyControl = py::class_<Control, std::shared_ptr<Control>>;
94 using PyClass = py::class_<Class, std::shared_ptr<Class>, Prior>;
96 PyControl clsControl(mod,
"SoftenedLinearPriorControl");
97 clsControl.def(py::init<>());
106 PyClass
cls(mod,
"SoftenedLinearPrior");
107 cls.def(py::init<Control>(),
"ctrl"_a);
108 cls.def(
"getControl", &Class::getControl, py::return_value_policy::copy);
109 cls.attr(
"Control") = clsControl;
114 py::module::import(
"lsst.meas.modelfit.mixture");
117 declareMixturePrior(mod);
118 declareSemiEmpiricalPrior(mod);
119 declareSoftenedLinearPrior(mod);
PYBIND11_MODULE(camera, mod)
A base class for image defects.
#define LSST_DECLARE_CONTROL_FIELD(WRAPPER, CLASS, NAME)
Macro used to wrap fields declared by LSST_CONTROL_FIELD using Pybind11.