Commit d65fe6d8 authored by Jason Rhinelander's avatar Jason Rhinelander

Updated single_peak_search for eris return value change

parent 515add7d
......@@ -10,13 +10,20 @@ namespace pyeris {
PYBIND11_PLUGIN(algorithms) {
py::module m("eris.algorithms", "eris interface for Python -- various algorithms and utilities");
py::class_<eris::single_peak_result>(m, "single_peak_result")
.def_readonly("arg", &eris::single_peak_result::arg, "The argument that maximizes the function given to single_peak_search()")
.def_readonly("max", &eris::single_peak_result::max, "The maximum (i.e. the value at .arg) of the function given to single_peak_search()")
.def_readonly("inside", &eris::single_peak_result::inside, "Will be true if .arg is strictly inside the end-points given to single_peak_search(). If false, the maximum was an end-point (suggesting that the peak is actually outside the given range).")
m.def("single_peak_search", &eris::single_peak_search,
"f"_a, "left"_a, "right"_a, "tol_rel"_a = 1e-10, "tol_abs"_a = 1e-20,
"Performs a \"golden section search\" to find the maximum of a single-peaked function, "
"`f`, between two limits. `f` should be a function that takes a float and returns a "
"float. `left` and `right` should points on either side of the maximum of `f`. "
"`tol_rel` is the relative size of the search domain (i.e. `right-left`) at which to stop "
"iterating (iteration stops when either or these tolerances are met)");
"iterating (iteration stops when either or these tolerances are met).\n\nReturns a"
"single_peak_result instance containing the argument and maximum at that argument.");
return m.ptr();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment