From 7b9a65e7bbf0e21f5e9003fa3461765fee3020a5 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Tue, 21 Nov 2023 19:17:55 -0700 Subject: [PATCH] Add loads to TrkConfig Will release version 2.0.0-beta.0 --- Cargo.toml | 2 +- src/python/orbit_determination/trkconfig.rs | 6 ++++++ tests/python/test_orbit_determination.py | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e0510659..8eaaedd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 "] description = "A high-fidelity space mission toolkit, with orbit propagation, estimation and some systems engineering" diff --git a/src/python/orbit_determination/trkconfig.rs b/src/python/orbit_determination/trkconfig.rs index 57dc4d1a..4355bf58 100644 --- a/src/python/orbit_determination/trkconfig.rs +++ b/src/python/orbit_determination/trkconfig.rs @@ -128,6 +128,12 @@ impl TrkConfig { Ok(()) } + #[classmethod] + /// Loads the TrkConfig from its YAML representation + fn loads(_cls: &PyType, state: &PyAny) -> Result { + depythonize(state).map_err(|e| ConfigError::InvalidConfig(e.to_string())) + } + #[getter] fn get_sampling(&self) -> PyResult { Ok(self.sampling) diff --git a/tests/python/test_orbit_determination.py b/tests/python/test_orbit_determination.py index d7af97c4..d5c7c56d 100644 --- a/tests/python/test_orbit_determination.py +++ b/tests/python/test_orbit_determination.py @@ -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)