Skip to content

Commit

Permalink
Updated python interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
geosarr committed Aug 10, 2024
1 parent 1493727 commit 12d4167
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions py-tuutal/src/first_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ macro_rules! first_order_method {
wrap_vec_func_scalar!(py, f, f_kwargs),
wrap_vec_func_vec!(py, g, g_kwargs),
&x0.as_array().to_owned(),
&DescentParameter::$name(gamma, beta),
DescentParameter::$name(gamma, beta),
gtol,
maxiter,
) {
Ok(value) => Ok(value.into_pyarray_bound(py)),
Ok((x, _fx)) => Ok(x.into_pyarray_bound(py)),
Err(error) => match error {
TuutalError::Convergence {
iterate: x,
Expand Down
4 changes: 2 additions & 2 deletions py-tuutal/src/zero_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn nelder_mead<'py>(
adaptive.unwrap_or(false),
bounds,
) {
Ok(value) => Ok(value.into_pyarray_bound(py)),
Ok((x, _fx)) => Ok(x.into_pyarray_bound(py)),
Err(error) => match error {
// Maybe better to throw also the current iterate and the number
// actual function calls for this exception.
Expand Down Expand Up @@ -142,7 +142,7 @@ pub fn brent_unbounded(
kwargs: Option<&Bound<'_, PyDict>>,
) -> PyResult<(f64, f64, usize)> {
let func = wrap_scalar_func_scalar!(py, f, kwargs);
let brack = brack.map_or(None, |v| Some([v.0, v.1]));
let brack = brack.map(|v| [v.0, v.1]);
match if let Some(val) = brack {
brent_unbounded_rs(func, Some(&[val[0], val[1]]), maxiter, xtol)
} else {
Expand Down

0 comments on commit 12d4167

Please sign in to comment.