Skip to main content

nyx_space/propagators/
python.rs

1use super::IntegratorOptions;
2use hifitime::Duration;
3use pyo3::prelude::*;
4
5#[pymethods]
6impl IntegratorOptions {
7    #[pyo3(signature=(min_step=None, max_step=None, tolerance=None))]
8    #[new]
9    fn py_new(
10        min_step: Option<Duration>,
11        max_step: Option<Duration>,
12        tolerance: Option<f64>,
13    ) -> Self {
14        let mut opts = Self::default();
15        if let Some(min_step) = min_step {
16            opts.set_min_step(min_step);
17        }
18        if let Some(max_step) = max_step {
19            opts.set_max_step(max_step);
20        }
21        if let Some(tolerance) = tolerance {
22            opts.tolerance = tolerance;
23        }
24        opts.fixed_step = opts.min_step == opts.max_step;
25        opts
26    }
27
28    #[getter]
29    fn get_min_step(&self) -> Duration {
30        self.min_step
31    }
32    #[getter]
33    fn get_max_step(&self) -> Duration {
34        self.max_step
35    }
36    #[getter]
37    fn get_tolerance(&self) -> f64 {
38        self.tolerance
39    }
40    fn __str__(&self) -> String {
41        format!("{self}")
42    }
43    fn __repr__(&self) -> String {
44        format!("{self} @ {self:p}")
45    }
46}