Skip to content

Commit

Permalink
Merge pull request #253 from nyx-space/250-python-spacecraftdynamics-…
Browse files Browse the repository at this point in the history
…can-only-be-loaded-from-file

Add loads to TrkConfig
  • Loading branch information
ChristopherRabotin committed Nov 22, 2023
2 parents 6741e2b + 7b9a65e commit 81367af
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 <christopher.rabotin@gmail.com>"]
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 81367af

Please sign in to comment.