From 4da272792dc218420f5e9dd99ae2884090f4359e Mon Sep 17 00:00:00 2001 From: Chad Baker Date: Wed, 3 Apr 2024 13:12:25 -0600 Subject: [PATCH] made use of `Network::from_file` consistent with Python API --- rust/altrios-core/src/meet_pass/dispatch.rs | 3 +-- rust/altrios-core/src/meet_pass/train_disp/mod.rs | 6 ++---- rust/altrios-core/src/track/link/link_impl.rs | 9 +++++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/rust/altrios-core/src/meet_pass/dispatch.rs b/rust/altrios-core/src/meet_pass/dispatch.rs index 823226da..ce7d75c7 100644 --- a/rust/altrios-core/src/meet_pass/dispatch.rs +++ b/rust/altrios-core/src/meet_pass/dispatch.rs @@ -303,8 +303,7 @@ mod test_dispatch { fn test_simple_dispatch() { let mut network_file_path = project_root::get_project_root().unwrap(); network_file_path.push("../python/altrios/resources/networks/Taconite.yaml"); - let network = - Vec::::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap(); + let network = Network::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap(); network.validate().unwrap(); let train_sims = vec![ diff --git a/rust/altrios-core/src/meet_pass/train_disp/mod.rs b/rust/altrios-core/src/meet_pass/train_disp/mod.rs index c280544a..759ff49e 100644 --- a/rust/altrios-core/src/meet_pass/train_disp/mod.rs +++ b/rust/altrios-core/src/meet_pass/train_disp/mod.rs @@ -222,8 +222,7 @@ mod test_train_disp { fn test_make_train_fwd() { let mut network_file_path = project_root::get_project_root().unwrap(); network_file_path.push("../python/altrios/resources/networks/Taconite.yaml"); - let network = - Vec::::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap(); + let network = Network::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap(); network.validate().unwrap(); let speed_limit_train_sim = crate::train::speed_limit_train_sim_fwd(); @@ -246,8 +245,7 @@ mod test_train_disp { // TODO: Make this test depend on a better file let mut network_file_path = project_root::get_project_root().unwrap(); network_file_path.push("../python/altrios/resources/networks/Taconite.yaml"); - let network = - Vec::::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap(); + let network = Network::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap(); network.validate().unwrap(); let speed_limit_train_sim = crate::train::speed_limit_train_sim_rev(); diff --git a/rust/altrios-core/src/track/link/link_impl.rs b/rust/altrios-core/src/track/link/link_impl.rs index a0cb4ea0..5c12d834 100644 --- a/rust/altrios-core/src/track/link/link_impl.rs +++ b/rust/altrios-core/src/track/link/link_impl.rs @@ -246,6 +246,15 @@ impl ObjState for Link { /// Python pub struct Network(pub Vec); +impl ObjState for Network { + fn is_fake(&self) -> bool { + self.0.is_fake() + } + fn validate(&self) -> ValidationResults { + self.0.validate() + } +} + impl SerdeAPI for Network { fn from_file>(filepath: P) -> anyhow::Result { let filepath = filepath.as_ref();