22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
27 #include "numpy/arrayobject.h"
28 #include "ndarray/pybind11.h"
32 namespace py = pybind11;
33 using namespace pybind11::literals;
41 template <
typename FittingFunc>
42 static void declareLeastSqFitter2d(py::module &mod, std::string
const &name) {
43 py::class_<LeastSqFitter2d<FittingFunc>, std::shared_ptr<LeastSqFitter2d<FittingFunc>>> cls(mod,
46 cls.def(py::init<std::vector<double>
const &, std::vector<double>
const &, std::vector<double>
const &,
47 std::vector<double>
const &,
int>(),
48 "x"_a,
"y"_a,
"z"_a,
"s"_a,
"order"_a);
50 cls.def(
"getParams", &LeastSqFitter2d<FittingFunc>::getParams);
51 cls.def(
"getErrors", &LeastSqFitter2d<FittingFunc>::getErrors);
52 cls.def(
"valueAt", &LeastSqFitter2d<FittingFunc>::valueAt,
"x"_a,
"y"_a);
53 cls.def(
"residuals", &LeastSqFitter2d<FittingFunc>::residuals);
54 cls.def(
"getChiSq", &LeastSqFitter2d<FittingFunc>::getChiSq);
55 cls.def(
"getReducedChiSq", &LeastSqFitter2d<FittingFunc>::getReducedChiSq);
61 py::module mod(
"leastSqFitter2d");
64 if (_import_array() < 0) {
65 PyErr_SetString(PyExc_ImportError,
"numpy.core.multiarray failed to import");
69 declareLeastSqFitter2d<afw::math::PolynomialFunction1<double>>(mod,
"LeastSqFitter2dPoly");
PYBIND11_PLUGIN(makeMatchStatistics)