Skip to content

Commit 81367af

Browse files
Merge pull request #253 from nyx-space/250-python-spacecraftdynamics-can-only-be-loaded-from-file
Add loads to TrkConfig
2 parents 6741e2b + 7b9a65e commit 81367af

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "nyx-space"
33
build = "build.rs"
4-
version = "2.0.0-beta-dev"
4+
version = "2.0.0-beta.0"
55
edition = "2021"
66
authors = ["Christopher Rabotin <christopher.rabotin@gmail.com>"]
77
description = "A high-fidelity space mission toolkit, with orbit propagation, estimation and some systems engineering"

src/python/orbit_determination/trkconfig.rs

+6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ impl TrkConfig {
128128
Ok(())
129129
}
130130

131+
#[classmethod]
132+
/// Loads the TrkConfig from its YAML representation
133+
fn loads(_cls: &PyType, state: &PyAny) -> Result<Self, ConfigError> {
134+
depythonize(state).map_err(|e| ConfigError::InvalidConfig(e.to_string()))
135+
}
136+
131137
#[getter]
132138
fn get_sampling(&self) -> PyResult<Duration> {
133139
Ok(self.sampling)

tests/python/test_orbit_determination.py

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def test_filter_arc():
7777
print(trk_cfg_demo.dumps())
7878
unpkld = pickle.loads(pickle.dumps(trk_cfg_demo))
7979
assert unpkld == trk_cfg_demo
80+
# Check that we can also call the `.loads` function directly
81+
assert TrkConfig.loads(trk_cfg_demo.dumps()) == trk_cfg_demo
8082

8183
# Load the trajectory
8284
traj = TrajectoryLoader(traj_file)

0 commit comments

Comments
 (0)