Skip to content

Commit

Permalink
Add loads to TrkConfig
Browse files Browse the repository at this point in the history
Will release version 2.0.0-beta.0
  • Loading branch information
ChristopherRabotin committed Nov 22, 2023
1 parent 6741e2b commit 7b9a65e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "nyx-space"
build = "build.rs"
version = "2.0.0-beta-dev"
version = "2.0.0-beta.0"
edition = "2021"
authors = ["Christopher Rabotin <[email protected]>"]
description = "A high-fidelity space mission toolkit, with orbit propagation, estimation and some systems engineering"
Expand Down
6 changes: 6 additions & 0 deletions src/python/orbit_determination/trkconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ impl TrkConfig {
Ok(())
}

#[classmethod]
/// Loads the TrkConfig from its YAML representation
fn loads(_cls: &PyType, state: &PyAny) -> Result<Self, ConfigError> {
depythonize(state).map_err(|e| ConfigError::InvalidConfig(e.to_string()))
}

#[getter]
fn get_sampling(&self) -> PyResult<Duration> {
Ok(self.sampling)
Expand Down
2 changes: 2 additions & 0 deletions tests/python/test_orbit_determination.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def test_filter_arc():
print(trk_cfg_demo.dumps())
unpkld = pickle.loads(pickle.dumps(trk_cfg_demo))
assert unpkld == trk_cfg_demo
# Check that we can also call the `.loads` function directly
assert TrkConfig.loads(trk_cfg_demo.dumps()) == trk_cfg_demo

# Load the trajectory
traj = TrajectoryLoader(traj_file)
Expand Down

0 comments on commit 7b9a65e

Please sign in to comment.