24#include "pybind11/pybind11.h"
27#include "ndarray/pybind11.h"
36using namespace pybind11::literals;
44 using PyPrior = py::class_<Prior, std::shared_ptr<Prior>>;
46 wrappers.
wrapType(PyPrior(wrappers.module,
"Prior"), [](
auto &mod,
auto &cls) {
47 cls.def(
"getTag", &Prior::getTag);
48 cls.def(
"evaluate", &Prior::evaluate,
"nonlinear"_a,
"amplitudes"_a);
49 cls.def(
"evaluateDerivatives", &Prior::evaluateDerivatives,
"nonlinear"_a,
"amplitudes"_a,
50 "nonlinearGradient"_a,
"amplitudeGradient"_a,
"nonlinearHessian"_a,
"amplitudeHessian"_a,
52 cls.def(
"marginalize", &Prior::marginalize,
"gradient"_a,
"hessian"_a,
"nonlinear"_a);
53 cls.def(
"maximize", &Prior::maximize,
"gradient"_a,
"hessian"_a,
"nonlinear"_a,
"amplitudes"_a);
54 cls.def(
"drawAmplitudes", &Prior::drawAmplitudes,
"gradient"_a,
"hessian"_a,
"nonlinear"_a,
"rng"_a,
55 "amplitudes"_a,
"weights"_a,
"multiplyWeights"_a = false);
60 using Class = MixturePrior;
61 using PyClass = py::class_<Class, std::shared_ptr<Class>, Prior>;
62 wrappers.
wrapType(
PyClass(wrappers.module,
"MixturePrior"), [](
auto &mod,
auto &cls) {
63 cls.def(py::init<std::shared_ptr<Mixture>, std::string const &>(),
"mixture"_a,
"tag"_a =
"");
64 cls.def_static(
"getUpdateRestriction", &Class::getUpdateRestriction,
65 py::return_value_policy::reference);
66 cls.def(
"getMixture", &Class::getMixture);
72 using Class = SemiEmpiricalPrior;
73 using Control = SemiEmpiricalPriorControl;
74 using PyControl = py::class_<Control, std::shared_ptr<Control>>;
75 using PyClass = py::class_<Class, std::shared_ptr<Class>, Prior>;
77 static auto clsControl =
78 wrappers.
wrapType(PyControl(wrappers.module,
"SemiEmpiricalPriorControl"), [](
auto &mod,
auto &cls) {
79 cls.def(py::init<>());
80 LSST_DECLARE_CONTROL_FIELD(cls, Control, ellipticitySigma);
81 LSST_DECLARE_CONTROL_FIELD(cls, Control, ellipticityCore);
82 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusMinOuter);
83 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusMinInner);
84 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusMu);
85 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusSigma);
86 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusNu);
87 cls.def(
"validate", &Control::validate);
90 wrappers.
wrapType(
PyClass(wrappers.module,
"SemiEmpiricalPrior"), [](
auto &mod,
auto &cls) {
91 cls.def(py::init<Control>(),
"ctrl"_a);
92 cls.attr(
"Control") = clsControl;
98 using Class = SoftenedLinearPrior;
99 using Control = SoftenedLinearPriorControl;
100 using PyControl = py::class_<Control, std::shared_ptr<Control>>;
101 using PyClass = py::class_<Class, std::shared_ptr<Class>, Prior>;
103 static auto clsControl =
104 wrappers.
wrapType(PyControl(wrappers.module,
"SoftenedLinearPriorControl"), [](
auto &mod,
auto &cls) {
105 cls.def(py::init<>());
106 LSST_DECLARE_CONTROL_FIELD(cls, Control, ellipticityMaxOuter);
107 LSST_DECLARE_CONTROL_FIELD(cls, Control, ellipticityMaxInner);
108 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusMinOuter);
109 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusMinInner);
110 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusMaxOuter);
111 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusMaxInner);
112 LSST_DECLARE_CONTROL_FIELD(cls, Control, logRadiusMinMaxRatio);
115 wrappers.
wrapType(
PyClass(wrappers.module,
"SoftenedLinearPrior"), [](
auto &mod,
auto &cls) {
116 cls.def(py::init<Control>(),
"ctrl"_a);
117 cls.def(
"getControl", &Class::getControl, py::return_value_policy::copy);
118 cls.attr(
"Control") = clsControl;
127 declarePrior(wrappers);
128 declareMixturePrior(wrappers);
129 declareSemiEmpiricalPrior(wrappers);
130 declareSoftenedLinearPrior(wrappers);
A helper class for subdividing pybind11 module across multiple translation units (i....
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
py::class_< PixelAreaBoundedField, std::shared_ptr< PixelAreaBoundedField >, BoundedField > PyClass
void wrapPriors(lsst::cpputils::python::WrapperCollection &wrappers)