From b3cacfa8d01d7e7bf1a92c78549e4ba85dd50982 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Mon, 6 Apr 2020 22:38:26 +0200 Subject: [PATCH 1/3] Expose tol_grad in L-BFGS --- src/lib.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 15b0f89..ccd521b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -96,18 +96,14 @@ impl PyLBFGS { } } -#[pyfunction] -/// blah -fn lbfgs(m: usize) -> Py { +#[pyfunction(m="10", tol_grad="1.0e-5")] +/// lbfgs(m=10, tol_grad="1e-5") +fn lbfgs(m: usize, tol_grad: f64) -> Py { let gil_guard = Python::acquire_gil(); let py = gil_guard.python(); - Py::new( - py, - PyLBFGS { - solver: LBFGS::new(MoreThuenteLineSearch::new(), m), - }, - ) - .unwrap() + let solver = LBFGS::new(MoreThuenteLineSearch::new(), m) + .with_tol_grad(tol_grad); + Py::new(py, PyLBFGS { solver: solver }).unwrap() } #[pyfunction] From 3f65a106eadf78cca4de9da37378051a69edbc34 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Mon, 6 Apr 2020 23:00:19 +0200 Subject: [PATCH 2/3] Use argmin master --- Cargo.toml | 6 +++--- src/lib.rs | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c38421f..c9dfe97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,9 @@ name = "_lib" crate-type = ["cdylib"] [dependencies] -# argmin_core = { path = "../argmin-core" } -# argmin = { path = "../argmin", features = ["ctrlc", "ndarrayl"]} -argmin = {version = "0.2.6", features = ["ctrlc", "ndarrayl"]} +#argmin = { path = "../argmin", features = ["ctrlc", "ndarrayl"]} +#argmin = {version = "0.2.6", features = ["ctrlc", "ndarrayl"]} +argmin = {git = "https://github.com/argmin-rs/argmin" } pyo3 = { version = "0.8.5", features = ["extension-module"] } serde = "1.0" numpy = "0.7.0" diff --git a/src/lib.rs b/src/lib.rs index ccd521b..c493a2b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -96,13 +96,12 @@ impl PyLBFGS { } } -#[pyfunction(m="10", tol_grad="1.0e-5")] +#[pyfunction(m = "10", tol_grad = "1.0e-5")] /// lbfgs(m=10, tol_grad="1e-5") fn lbfgs(m: usize, tol_grad: f64) -> Py { let gil_guard = Python::acquire_gil(); let py = gil_guard.python(); - let solver = LBFGS::new(MoreThuenteLineSearch::new(), m) - .with_tol_grad(tol_grad); + let solver = LBFGS::new(MoreThuenteLineSearch::new(), m).with_tol_grad(tol_grad); Py::new(py, PyLBFGS { solver: solver }).unwrap() } From 1ed6680bf80e9847c614e27040c1e4718be1bd17 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Mon, 6 Apr 2020 23:01:47 +0200 Subject: [PATCH 3/3] Typo in function signature --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c493a2b..1ce747d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -96,8 +96,8 @@ impl PyLBFGS { } } -#[pyfunction(m = "10", tol_grad = "1.0e-5")] -/// lbfgs(m=10, tol_grad="1e-5") +#[pyfunction(m = "10", tol_grad = "1e-5")] +/// lbfgs(m=10, tol_grad=1e-5) fn lbfgs(m: usize, tol_grad: f64) -> Py { let gil_guard = Python::acquire_gil(); let py = gil_guard.python();