From 7bc7dec9b9cff5226d62d6554aadc4b5af57c909 Mon Sep 17 00:00:00 2001 From: Ed Younis Date: Sat, 18 Nov 2023 16:26:48 -0500 Subject: [PATCH] Fix python defined residuals --- src/python/minimizers/residual_fn.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/python/minimizers/residual_fn.rs b/src/python/minimizers/residual_fn.rs index d5f3ba5..6b1b2c4 100644 --- a/src/python/minimizers/residual_fn.rs +++ b/src/python/minimizers/residual_fn.rs @@ -52,11 +52,14 @@ impl ResidualFn for PyResidualFn { let py = gil.python(); let parameters = PyArray1::from_slice(py, params); let args = PyTuple::new(py, &[parameters]); - match self.cost_fn.call_method1(py, "get_cost", args) { + match self.cost_fn.call_method1(py, "get_residuals", args) { Ok(val) => val .extract::>(py) - .expect("Return type of get_cost was not a sequence of floats."), - Err(..) => panic!("Failed to call 'get_cost' on passed ResidualFunction."), // TODO: make a Python exception? + .expect("Return type of get_residuals was not a sequence of floats."), + Err(e) => { + println!("{:?}, {:?}, {:?}", e.get_type(py), e.value(py), e.traceback(py)); + panic!("Failed to call 'get_residuals' on passed ResidualFunction."); // TODO: make a Python exception? + }, } } }