diff --git a/Cargo.toml b/Cargo.toml index 8d44077d..565addf8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,7 @@ exclude = [ ] [workspace.dependencies] -# hifitime = "4.0.1" -hifitime = { path = "../hifitime" } +hifitime = "4.0.2" memmap2 = "0.9.4" crc32fast = "1.4.2" der = { version = "0.7.8", features = ["derive", "alloc", "real"] } diff --git a/anise-py/src/utils.rs b/anise-py/src/utils.rs index 6ce4e846..cebfe0ad 100644 --- a/anise-py/src/utils.rs +++ b/anise-py/src/utils.rs @@ -35,6 +35,7 @@ pub(crate) fn register_utils(parent_module: &Bound<'_, PyModule>) -> PyResult<() /// :type overwrite: bool, optional /// :rtype: None #[pyfunction] +#[pyo3(signature = (fk_file_path, anise_output_path, show_comments=None, overwrite=None))] fn convert_fk( fk_file_path: String, anise_output_path: String, @@ -60,6 +61,7 @@ fn convert_fk( /// :type overwrite: bool, optional /// :rtype: None #[pyfunction] +#[pyo3(signature = (pck_file_path, gm_file_path, anise_output_path, overwrite=None))] fn convert_tpc( pck_file_path: String, gm_file_path: String, diff --git a/anise/src/almanac/metaload/metaalmanac.rs b/anise/src/almanac/metaload/metaalmanac.rs index 54a2dba3..d21b0e4e 100644 --- a/anise/src/almanac/metaload/metaalmanac.rs +++ b/anise/src/almanac/metaload/metaalmanac.rs @@ -57,9 +57,13 @@ impl MetaAlmanac { } /// Fetch all of the URIs and return a loaded Almanac - pub(crate) fn _process(&mut self, autodelete: bool) -> AlmanacResult { + /// When downloading the data, ANISE will create a temporarily lock file to prevent race conditions + /// where multiple processes download the data at the same time. Set `autodelete` to true to delete + /// this lock file if a dead lock is detected after 10 seconds. Set this flag to false if you have + /// more than ten processes which may attempt to download files in parallel. + pub fn process(&mut self, autodelete: bool) -> AlmanacResult { for (fno, file) in self.files.iter_mut().enumerate() { - file._process(autodelete).context(MetaSnafu { + file.process(autodelete).context(MetaSnafu { fno, file: file.clone(), })?; @@ -72,16 +76,6 @@ impl MetaAlmanac { Ok(ctx) } - /// Fetch all of the URIs and return a loaded Almanac - /// When downloading the data, ANISE will create a temporarily lock file to prevent race conditions - /// where multiple processes download the data at the same time. Set `autodelete` to true to delete - /// this lock file if a dead lock is detected after 10 seconds. Set this flag to false if you have - /// more than ten processes which may attempt to download files in parallel. - #[cfg(not(feature = "python"))] - pub fn process(&mut self, autodelete: bool) -> AlmanacResult { - self._process(autodelete) - } - /// Returns an Almanac loaded from the latest NAIF data via the `default` MetaAlmanac. /// The MetaAlmanac will download the DE440s.bsp file, the PCK0008.PCA, the full Moon Principal Axis BPC (moon_pa_de440_200625) and the latest high precision Earth kernel from JPL. /// @@ -95,7 +89,6 @@ impl MetaAlmanac { /// /// Note that the `earth_latest_high_prec.bpc` file is regularly updated daily (or so). As such, /// if queried at some future time, the Earth rotation parameters may have changed between two queries. - #[cfg(not(feature = "python"))] pub fn latest() -> AlmanacResult { Self::default().process(true) } @@ -144,6 +137,7 @@ impl MetaAlmanac { impl MetaAlmanac { /// Loads the provided path as a Dhall file. If no path is provided, creates an empty MetaAlmanac that can store MetaFiles. #[new] + #[pyo3(signature=(maybe_path=None))] pub fn py_new(maybe_path: Option) -> Result { match maybe_path { Some(path) => Self::new(path), @@ -179,13 +173,15 @@ impl MetaAlmanac { /// :type autodelete: bool, optional /// :rtype: MetaAlmanac #[classmethod] - fn latest( + #[pyo3(name = "latest")] + #[pyo3(signature=(autodelete=None))] + fn py_latest( _cls: &Bound<'_, PyType>, py: Python, autodelete: Option, ) -> AlmanacResult { let mut meta = Self::default(); - py.allow_threads(|| match meta._process(autodelete.unwrap_or(false)) { + py.allow_threads(|| match meta.process(autodelete.unwrap_or(false)) { Ok(almanac) => Ok(almanac), Err(e) => Err(e), }) @@ -199,8 +195,10 @@ impl MetaAlmanac { /// /// :type autodelete: bool, optional /// :rtype: Almanac - pub fn process(&mut self, py: Python, autodelete: Option) -> AlmanacResult { - py.allow_threads(|| self._process(autodelete.unwrap_or(true))) + #[pyo3(name = "process")] + #[pyo3(signature=(autodelete=None))] + pub fn py_process(&mut self, py: Python, autodelete: Option) -> AlmanacResult { + py.allow_threads(|| self.process(autodelete.unwrap_or(true))) } fn __str__(&self) -> String { diff --git a/anise/src/almanac/metaload/metafile.rs b/anise/src/almanac/metaload/metafile.rs index 90681200..a42f058f 100644 --- a/anise/src/almanac/metaload/metafile.rs +++ b/anise/src/almanac/metaload/metafile.rs @@ -56,12 +56,7 @@ impl MetaFile { /// Processes this MetaFile by downloading it if it's a URL and sets this structure's `uri` field to the local path /// /// This function modified `self` and changes the URI to be the path to the downloaded file. - #[cfg(not(feature = "python"))] pub fn process(&mut self, autodelete: bool) -> Result<(), MetaAlmanacError> { - self._process(autodelete) - } - - pub(crate) fn _process(&mut self, autodelete: bool) -> Result<(), MetaAlmanacError> { // First, parse environment variables if any. self.uri = replace_env_vars(&self.uri); match Url::parse(&self.uri) { @@ -268,6 +263,7 @@ impl MetaFile { impl MetaFile { /// Builds a new MetaFile from the provided URI and optionally its CRC32 checksum. #[new] + #[pyo3(signature=(uri, crc32=None))] pub fn py_new(uri: String, crc32: Option) -> Self { Self { uri, crc32 } } @@ -296,12 +292,13 @@ impl MetaFile { /// /// :type autodelete: bool, optional /// :rtype: None - pub fn process( + #[pyo3(name = "process", signature=(autodelete=None))] + pub fn py_process( &mut self, py: Python, autodelete: Option, ) -> Result<(), MetaAlmanacError> { - py.allow_threads(|| self._process(autodelete.unwrap_or(false))) + py.allow_threads(|| self.process(autodelete.unwrap_or(false))) } /// :rtype: str diff --git a/anise/src/almanac/metaload/mod.rs b/anise/src/almanac/metaload/mod.rs index cd1b25fa..172db6fa 100644 --- a/anise/src/almanac/metaload/mod.rs +++ b/anise/src/almanac/metaload/mod.rs @@ -61,7 +61,7 @@ impl Almanac { mut metafile: MetaFile, autodelete: bool, ) -> AlmanacResult { - metafile._process(autodelete).context(MetaSnafu { + metafile.process(autodelete).context(MetaSnafu { fno: 0_usize, file: metafile.clone(), })?; diff --git a/anise/src/astro/mod.rs b/anise/src/astro/mod.rs index ae0f65da..849c6197 100644 --- a/anise/src/astro/mod.rs +++ b/anise/src/astro/mod.rs @@ -79,6 +79,7 @@ impl AzElRange { impl AzElRange { /// Initializes a new AzElRange instance #[new] + #[pyo3(signature=(epoch, azimuth_deg, elevation_deg, range_km, range_rate_km_s, obstructed_by=None))] pub fn py_new( epoch: Epoch, azimuth_deg: f64, diff --git a/anise/src/frames/frame.rs b/anise/src/frames/frame.rs index 92a821eb..58238aeb 100644 --- a/anise/src/frames/frame.rs +++ b/anise/src/frames/frame.rs @@ -98,6 +98,7 @@ impl Frame { impl Frame { /// Initializes a new [Frame] provided its ephemeris and orientation identifiers, and optionally its gravitational parameter (in km^3/s^2) and optionally its shape (cf. [Ellipsoid]). #[new] + #[pyo3(signature=(ephemeris_id, orientation_id, mu_km3_s2=None, shape=None))] pub fn py_new( ephemeris_id: NaifId, orientation_id: NaifId, diff --git a/anise/src/math/rotation/dcm_py.rs b/anise/src/math/rotation/dcm_py.rs index 9843cf4c..ee2ab4af 100644 --- a/anise/src/math/rotation/dcm_py.rs +++ b/anise/src/math/rotation/dcm_py.rs @@ -23,6 +23,7 @@ use pyo3::types::PyType; #[pymethods] impl DCM { #[new] + #[pyo3(signature=(np_rot_mat, from_id, to_id, np_rot_mat_dt=None))] pub fn py_new<'py>( np_rot_mat: PyReadonlyArray2<'py, f64>, from_id: NaifId, diff --git a/anise/src/naif/daf/data_types.rs b/anise/src/naif/daf/data_types.rs index 6985decb..d437e5df 100644 --- a/anise/src/naif/daf/data_types.rs +++ b/anise/src/naif/daf/data_types.rs @@ -19,7 +19,7 @@ use super::DAFError; #[cfg(feature = "python")] use pyo3::prelude::*; -#[cfg_attr(feature = "python", pyclass)] +#[cfg_attr(feature = "python", pyclass(eq, eq_int))] #[derive(Copy, Clone, Debug, PartialEq)] #[repr(u8)] pub enum DataType { diff --git a/anise/src/structure/planetocentric/ellipsoid.rs b/anise/src/structure/planetocentric/ellipsoid.rs index 34a7bb47..ca2bb89b 100644 --- a/anise/src/structure/planetocentric/ellipsoid.rs +++ b/anise/src/structure/planetocentric/ellipsoid.rs @@ -74,6 +74,7 @@ impl Ellipsoid { /// All units are in kilometers. If the semi minor equatorial radius is not provided, a bi-axial spheroid will be created using the semi major equatorial radius as /// the equatorial radius and using the provided polar axis radius. If only the semi major equatorial radius is provided, a perfect sphere will be built. #[new] + #[pyo3(signature=(semi_major_equatorial_radius_km, polar_radius_km=None, semi_minor_equatorial_radius_km=None))] fn py_new( semi_major_equatorial_radius_km: f64, polar_radius_km: Option,