diff --git a/src/od/process/conf.rs b/src/od/process/conf.rs index 1575b419..fb1f501f 100644 --- a/src/od/process/conf.rs +++ b/src/od/process/conf.rs @@ -27,7 +27,6 @@ use pyo3::prelude::*; /// Defines the stopping condition for the smoother #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "python", pyclass)] pub enum SmoothingArc { /// Stop smoothing when the gap between estimate is the provided floating point number in seconds TimeGap(Duration), @@ -39,43 +38,6 @@ pub enum SmoothingArc { All, } -#[cfg(feature = "python")] -#[pymethods] -impl SmoothingArc { - #[new] - fn py_new( - strategy: Option, - duration: Option, - epoch: Option, - ) -> Result { - if let Some(strategy) = strategy { - match strategy.to_lowercase().trim() { - "all" => Ok(Self::All), - "prediction" => Ok(Self::Prediction), - _ => Err(NyxError::CustomError(format!( - "strategy should be `all` or `prediction`" - ))), - } - } else if Some(duration) = duration { - Ok(Self::TimeGap(duration)) - } else if Some(epoch) = epoch { - Ok(Self::Epoch(epoch)) - } else { - Err(NyxError::CustomError( - "Smoothing arc strategy not specified", - )) - } - } - - fn __repr__(&self) -> String { - format!("{self}") - } - - fn __str__(&self) -> String { - format!("Smoothing {self}") - } -} - impl fmt::Display for SmoothingArc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { @@ -121,21 +83,41 @@ impl IterationConf { impl IterationConf { #[new] fn py_new( - smoother: SmoothingArc, + strategy: Option, + duration: Option, + epoch: Option, absolute_tol: Option, relative_tol: Option, max_iterations: Option, max_divergences: Option, force_failure: Option, - ) -> Self { + ) -> Result { let mut me = Self::default(); - me.smoother = smoother; + me.smoother = if let Some(strategy) = strategy { + match strategy.to_lowercase().trim() { + "all" => SmoothingArc::All, + "prediction" => SmoothingArc::Prediction, + _ => { + return Err(NyxError::CustomError(format!( + "strategy should be `all` or `prediction`" + ))) + } + } + } else if let Some(duration) = duration { + SmoothingArc::TimeGap(duration) + } else if let Some(epoch) = epoch { + SmoothingArc::Epoch(epoch) + } else { + return Err(NyxError::CustomError( + "Smoothing arc strategy not specified".to_string(), + )); + }; if let Some(abs_tol) = absolute_tol { me.absolute_tol = abs_tol; } if let Some(rel_tol) = relative_tol { - me.relative_tol = rel_toll + me.relative_tol = rel_tol; } if let Some(max_it) = max_iterations { @@ -150,7 +132,7 @@ impl IterationConf { me.force_failure = force_failure; } - me + Ok(me) } fn __repr__(&self) -> String { diff --git a/src/python/orbit_determination/mod.rs b/src/python/orbit_determination/mod.rs index ad049cfd..df20987b 100644 --- a/src/python/orbit_determination/mod.rs +++ b/src/python/orbit_determination/mod.rs @@ -19,7 +19,7 @@ use crate::io::tracking_data::DynamicTrackingArc; use crate::io::ExportCfg; use crate::od::noise::GaussMarkov; -use crate::od::process::{FltResid, IterationConf, SmoothingArc}; +use crate::od::process::{FltResid, IterationConf}; pub use crate::od::simulator::TrkConfig; pub use crate::{io::ConfigError, od::prelude::GroundStation}; use pyo3::{prelude::*, py_run}; @@ -43,7 +43,6 @@ pub(crate) fn register_od(py: Python<'_>, parent_module: &PyModule) -> PyResult< sm.add_class::()?; sm.add_class::()?; sm.add_class::()?; - sm.add_class::()?; sm.add_class::()?; sm.add_function(wrap_pyfunction!(process_tracking_arc, sm)?)?; sm.add_function(wrap_pyfunction!(predictor, sm)?)?;