Skip to content

Commit 45d8d76

Browse files
Update to hifitime 4.0.2 (for pyo3)
Fixed half of the deprecation warnings of pyo3 0.23
1 parent 22fdcc9 commit 45d8d76

File tree

10 files changed

+28
-28
lines changed

10 files changed

+28
-28
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ exclude = [
2626
]
2727

2828
[workspace.dependencies]
29-
# hifitime = "4.0.1"
30-
hifitime = { path = "../hifitime" }
29+
hifitime = "4.0.2"
3130
memmap2 = "0.9.4"
3231
crc32fast = "1.4.2"
3332
der = { version = "0.7.8", features = ["derive", "alloc", "real"] }

anise-py/src/utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub(crate) fn register_utils(parent_module: &Bound<'_, PyModule>) -> PyResult<()
3535
/// :type overwrite: bool, optional
3636
/// :rtype: None
3737
#[pyfunction]
38+
#[pyo3(signature = (fk_file_path, anise_output_path, show_comments=None, overwrite=None))]
3839
fn convert_fk(
3940
fk_file_path: String,
4041
anise_output_path: String,
@@ -60,6 +61,7 @@ fn convert_fk(
6061
/// :type overwrite: bool, optional
6162
/// :rtype: None
6263
#[pyfunction]
64+
#[pyo3(signature = (pck_file_path, gm_file_path, anise_output_path, overwrite=None))]
6365
fn convert_tpc(
6466
pck_file_path: String,
6567
gm_file_path: String,

anise/src/almanac/metaload/metaalmanac.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ impl MetaAlmanac {
5757
}
5858

5959
/// Fetch all of the URIs and return a loaded Almanac
60-
pub(crate) fn _process(&mut self, autodelete: bool) -> AlmanacResult<Almanac> {
60+
/// When downloading the data, ANISE will create a temporarily lock file to prevent race conditions
61+
/// where multiple processes download the data at the same time. Set `autodelete` to true to delete
62+
/// this lock file if a dead lock is detected after 10 seconds. Set this flag to false if you have
63+
/// more than ten processes which may attempt to download files in parallel.
64+
pub fn process(&mut self, autodelete: bool) -> AlmanacResult<Almanac> {
6165
for (fno, file) in self.files.iter_mut().enumerate() {
62-
file._process(autodelete).context(MetaSnafu {
66+
file.process(autodelete).context(MetaSnafu {
6367
fno,
6468
file: file.clone(),
6569
})?;
@@ -72,16 +76,6 @@ impl MetaAlmanac {
7276
Ok(ctx)
7377
}
7478

75-
/// Fetch all of the URIs and return a loaded Almanac
76-
/// When downloading the data, ANISE will create a temporarily lock file to prevent race conditions
77-
/// where multiple processes download the data at the same time. Set `autodelete` to true to delete
78-
/// this lock file if a dead lock is detected after 10 seconds. Set this flag to false if you have
79-
/// more than ten processes which may attempt to download files in parallel.
80-
#[cfg(not(feature = "python"))]
81-
pub fn process(&mut self, autodelete: bool) -> AlmanacResult<Almanac> {
82-
self._process(autodelete)
83-
}
84-
8579
/// Returns an Almanac loaded from the latest NAIF data via the `default` MetaAlmanac.
8680
/// 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.
8781
///
@@ -95,7 +89,6 @@ impl MetaAlmanac {
9589
///
9690
/// Note that the `earth_latest_high_prec.bpc` file is regularly updated daily (or so). As such,
9791
/// if queried at some future time, the Earth rotation parameters may have changed between two queries.
98-
#[cfg(not(feature = "python"))]
9992
pub fn latest() -> AlmanacResult<Almanac> {
10093
Self::default().process(true)
10194
}
@@ -144,6 +137,7 @@ impl MetaAlmanac {
144137
impl MetaAlmanac {
145138
/// Loads the provided path as a Dhall file. If no path is provided, creates an empty MetaAlmanac that can store MetaFiles.
146139
#[new]
140+
#[pyo3(signature=(maybe_path=None))]
147141
pub fn py_new(maybe_path: Option<String>) -> Result<Self, MetaAlmanacError> {
148142
match maybe_path {
149143
Some(path) => Self::new(path),
@@ -179,13 +173,15 @@ impl MetaAlmanac {
179173
/// :type autodelete: bool, optional
180174
/// :rtype: MetaAlmanac
181175
#[classmethod]
182-
fn latest(
176+
#[pyo3(name = "latest")]
177+
#[pyo3(signature=(autodelete=None))]
178+
fn py_latest(
183179
_cls: &Bound<'_, PyType>,
184180
py: Python,
185181
autodelete: Option<bool>,
186182
) -> AlmanacResult<Almanac> {
187183
let mut meta = Self::default();
188-
py.allow_threads(|| match meta._process(autodelete.unwrap_or(false)) {
184+
py.allow_threads(|| match meta.process(autodelete.unwrap_or(false)) {
189185
Ok(almanac) => Ok(almanac),
190186
Err(e) => Err(e),
191187
})
@@ -199,8 +195,10 @@ impl MetaAlmanac {
199195
///
200196
/// :type autodelete: bool, optional
201197
/// :rtype: Almanac
202-
pub fn process(&mut self, py: Python, autodelete: Option<bool>) -> AlmanacResult<Almanac> {
203-
py.allow_threads(|| self._process(autodelete.unwrap_or(true)))
198+
#[pyo3(name = "process")]
199+
#[pyo3(signature=(autodelete=None))]
200+
pub fn py_process(&mut self, py: Python, autodelete: Option<bool>) -> AlmanacResult<Almanac> {
201+
py.allow_threads(|| self.process(autodelete.unwrap_or(true)))
204202
}
205203

206204
fn __str__(&self) -> String {

anise/src/almanac/metaload/metafile.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ impl MetaFile {
5656
/// Processes this MetaFile by downloading it if it's a URL and sets this structure's `uri` field to the local path
5757
///
5858
/// This function modified `self` and changes the URI to be the path to the downloaded file.
59-
#[cfg(not(feature = "python"))]
6059
pub fn process(&mut self, autodelete: bool) -> Result<(), MetaAlmanacError> {
61-
self._process(autodelete)
62-
}
63-
64-
pub(crate) fn _process(&mut self, autodelete: bool) -> Result<(), MetaAlmanacError> {
6560
// First, parse environment variables if any.
6661
self.uri = replace_env_vars(&self.uri);
6762
match Url::parse(&self.uri) {
@@ -268,6 +263,7 @@ impl MetaFile {
268263
impl MetaFile {
269264
/// Builds a new MetaFile from the provided URI and optionally its CRC32 checksum.
270265
#[new]
266+
#[pyo3(signature=(uri, crc32=None))]
271267
pub fn py_new(uri: String, crc32: Option<u32>) -> Self {
272268
Self { uri, crc32 }
273269
}
@@ -296,12 +292,13 @@ impl MetaFile {
296292
///
297293
/// :type autodelete: bool, optional
298294
/// :rtype: None
299-
pub fn process(
295+
#[pyo3(name = "process", signature=(autodelete=None))]
296+
pub fn py_process(
300297
&mut self,
301298
py: Python,
302299
autodelete: Option<bool>,
303300
) -> Result<(), MetaAlmanacError> {
304-
py.allow_threads(|| self._process(autodelete.unwrap_or(false)))
301+
py.allow_threads(|| self.process(autodelete.unwrap_or(false)))
305302
}
306303

307304
/// :rtype: str

anise/src/almanac/metaload/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Almanac {
6161
mut metafile: MetaFile,
6262
autodelete: bool,
6363
) -> AlmanacResult<Self> {
64-
metafile._process(autodelete).context(MetaSnafu {
64+
metafile.process(autodelete).context(MetaSnafu {
6565
fno: 0_usize,
6666
file: metafile.clone(),
6767
})?;

anise/src/astro/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ impl AzElRange {
7979
impl AzElRange {
8080
/// Initializes a new AzElRange instance
8181
#[new]
82+
#[pyo3(signature=(epoch, azimuth_deg, elevation_deg, range_km, range_rate_km_s, obstructed_by=None))]
8283
pub fn py_new(
8384
epoch: Epoch,
8485
azimuth_deg: f64,

anise/src/frames/frame.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ impl Frame {
9898
impl Frame {
9999
/// 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]).
100100
#[new]
101+
#[pyo3(signature=(ephemeris_id, orientation_id, mu_km3_s2=None, shape=None))]
101102
pub fn py_new(
102103
ephemeris_id: NaifId,
103104
orientation_id: NaifId,

anise/src/math/rotation/dcm_py.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use pyo3::types::PyType;
2323
#[pymethods]
2424
impl DCM {
2525
#[new]
26+
#[pyo3(signature=(np_rot_mat, from_id, to_id, np_rot_mat_dt=None))]
2627
pub fn py_new<'py>(
2728
np_rot_mat: PyReadonlyArray2<'py, f64>,
2829
from_id: NaifId,

anise/src/naif/daf/data_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use super::DAFError;
1919
#[cfg(feature = "python")]
2020
use pyo3::prelude::*;
2121

22-
#[cfg_attr(feature = "python", pyclass)]
22+
#[cfg_attr(feature = "python", pyclass(eq, eq_int))]
2323
#[derive(Copy, Clone, Debug, PartialEq)]
2424
#[repr(u8)]
2525
pub enum DataType {

anise/src/structure/planetocentric/ellipsoid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ impl Ellipsoid {
7474
/// 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
7575
/// 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.
7676
#[new]
77+
#[pyo3(signature=(semi_major_equatorial_radius_km, polar_radius_km=None, semi_minor_equatorial_radius_km=None))]
7778
fn py_new(
7879
semi_major_equatorial_radius_km: f64,
7980
polar_radius_km: Option<f64>,

0 commit comments

Comments
 (0)