Skip to content

Commit

Permalink
all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Jan 15, 2025
1 parent 65d857a commit 6aa951b
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion python/altrios/altrios_pyo3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SerdeAPI(object):
@classmethod
def from_yaml(cls) -> Self: ...
@classmethod
def from_file(cls, skip_init=false) -> Self: ...
def from_file(cls, skip_init=False) -> Self: ...
def to_file(self): ...
def to_bincode(self) -> bytes: ...
def to_json(self) -> str: ...
Expand Down
2 changes: 1 addition & 1 deletion python/altrios/demos/sim_manager_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
t0_import = time.perf_counter()
t0_total = time.perf_counter()

rail_vehicles=[alt.RailVehicle.from_file(vehicle_file, skip_init=false)
rail_vehicles=[alt.RailVehicle.from_file(vehicle_file, skip_init=False)
for vehicle_file in Path(alt.resources_root() / "rolling_stock/").glob('*.yaml')]

location_map = alt.import_locations(alt.resources_root() / "networks/default_locations.csv")
Expand Down
4 changes: 2 additions & 2 deletions python/altrios/demos/version_migration_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def migrate_network() -> Tuple[alt.Network, alt.Network]:
old_network_path = alt.resources_root() / "networks/Taconite_v0.1.6.yaml"
new_network_path = alt.resources_root() / "networks/Taconite.yaml"

network_from_old = alt.Network.from_file(old_network_path, skip_init=false)
network_from_new = alt.Network.from_file(new_network_path, skip_init=false)
network_from_old = alt.Network.from_file(old_network_path, skip_init=False)
network_from_new = alt.Network.from_file(new_network_path, skip_init=False)

# `network_from_old` could be used to overwrite the file in the new format with
# ```
Expand Down
4 changes: 2 additions & 2 deletions python/altrios/rollout.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def simulate_prescribed_rollout(
else:
demand_paths.append(demand_file)

rail_vehicles=[alt.RailVehicle.from_file(vehicle_file, skip_init=false)
rail_vehicles=[alt.RailVehicle.from_file(vehicle_file, skip_init=False)
for vehicle_file in Path(alt.resources_root() / "rolling_stock/").glob('*.yaml')]

location_map = alt.import_locations(
str(alt.resources_root() / "networks/default_locations.csv")
)
network = alt.Network.from_file(network_filename_path, skip_init=false)
network = alt.Network.from_file(network_filename_path, skip_init=False)
sim_days = defaults.SIMULATION_DAYS
scenarios = []
for idx, scenario_year in enumerate(years):
Expand Down
9 changes: 6 additions & 3 deletions python/altrios/tests/test_serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ def test_pydict():
print(f"Elapsed time for json: {t_json:.3e} ns ")
print(f"JSON time per MessagePack time: {(t_json / t_msg):.3e} ")

# `to_yaml` is probably needed because of NAN variables
assert ts_msg == ts
assert ts_yaml == ts
# `to_pydict` is necessary because of some funkiness with direct equality comparison
assert ts_msg.to_pydict() == ts.to_pydict()
assert ts_yaml.to_pydict() == ts.to_pydict()

if __name__ == "__main__":
test_pydict()
2 changes: 1 addition & 1 deletion python/altrios/train_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ def run_train_planner(

if __name__ == "__main__":

rail_vehicles=[alt.RailVehicle.from_file(vehicle_file, skip_init=false)
rail_vehicles=[alt.RailVehicle.from_file(vehicle_file, skip_init=False)
for vehicle_file in Path(alt.resources_root() / "rolling_stock/").glob('*.yaml')]

location_map = alt.import_locations(
Expand Down
2 changes: 1 addition & 1 deletion rust/altrios-core/src/consist/consist_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use super::*;
);
}
fn get_hct(&self) -> String {
fn get_pdct(&self) -> String {
// make a `describe` function
match &self.pdct {
PowerDistributionControlType::RESGreedy(val) => format!("{val:?}"),
Expand Down
1 change: 1 addition & 0 deletions rust/altrios-core/src/consist/consist_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ impl SolvePower for FrontAndBack {
todo!() // not needed urgently
}
}

/// Variants of this enum are used to determine what control strategy gets used for distributing
/// power required from or delivered to during negative tractive power each locomotive.
#[derive(PartialEq, Clone, Deserialize, Serialize, Debug, SerdeAPI)]
Expand Down
2 changes: 1 addition & 1 deletion rust/altrios-core/src/track/link/speed/speed_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::collections::HashMap;

#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, SerdeAPI, Hash)]
#[repr(u8)]
#[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
#[cfg_attr(feature = "pyo3", pyclass(eq))]
/// Enum with variants representing train types
pub enum TrainType {
#[default]
Expand Down

0 comments on commit 6aa951b

Please sign in to comment.