pointsource_algs step length estimation support draft

Fri, 16 Jan 2026 19:41:32 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Fri, 16 Jan 2026 19:41:32 -0500
changeset 2
69002abe5dcb
parent 1
a4137aedcb3a

pointsource_algs step length estimation support

src/python_access/diff_mapping.rs file | annotate | diff | comparison | revisions
--- a/src/python_access/diff_mapping.rs	Thu Feb 26 09:32:12 2026 -0500
+++ b/src/python_access/diff_mapping.rs	Fri Jan 16 19:41:32 2026 -0500
@@ -11,7 +11,9 @@
 use ndarray::Dimension;
 use numpy::{Ix1, Ix2};
 use pointsource_algs::forward_model::{BoundedCurvature, BoundedCurvatureGuess};
-use pointsource_algs::prox_penalty::{RadonSquared, StepLengthBound, StepLengthBoundPair};
+use pointsource_algs::prox_penalty::{
+    RadonSquared, StepLengthBound, StepLengthBoundPair, StepLengthBoundValue,
+};
 use pyo3::conversion::FromPyObject;
 use pyo3::intern;
 use pyo3::prelude::*;
@@ -123,12 +125,14 @@
         where
             Domain: Space,
             Domain::Principal: IntoPyObject<'py>,
+            Self: Mapping<Domain>,
+            <Self as Mapping<Domain>>::Codomain:
+                ClosedSpace + for<'a> FromPyObject<'a, 'py, Error = PyErr>,
             //$derivative: Space + for<'py> FromPyObject<'py>,
             //f64 : for<'py> FromPyObject<'py>,
         {
             type Derivative = $derivative;
 
-            /// Compute the value of `self` at `x`.
             fn differential_impl<I: Instance<Domain>>(&self, x: I) -> $derivative {
                 // TODO: use references and internal mutability?
                 //x_py = x.own().to_python(py).unwrap();
@@ -198,13 +202,16 @@
     fn step_length_bound(
         &self,
         f: &PythonMapping<'py, Domain, f64, Differentiable<Marker>>,
-    ) -> DynResult<f64> {
+    ) -> StepLengthBoundValue<f64> {
         let m = intern!(f.obj.py(), "diff_lipschitz_factor");
-        process_error(
+        match process_error(
             "PythonMapping::diff_lipschitz_factor",
             f.obj.py(),
             f.obj.call_method0(m).and_then(|r| r.extract()),
-        )
+        ) {
+            Ok(v) => StepLengthBoundValue::UnreliableLipschitzFactor(v),
+            Err(_) => StepLengthBoundValue::Failure,
+        }
     }
 }
 

mercurial