Skip to content

Commit 7dc57f9

Browse files
authored
Merge pull request #57 from NREL/fix/speed-set-in-pyo3
exposed `SpeedSet` via pyo3
2 parents 4733a15 + 8dd7b19 commit 7dc57f9

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

python/altrios/altrios_pyo3.pyi

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SerdeAPI(object):
1515
def from_yaml(cls) -> Self: ...
1616
@classmethod
1717
def from_file(cls) -> Self: ...
18-
def to_file(self): ...
18+
def to_file(self): ...
1919
def to_bincode(self) -> bytes: ...
2020
def to_json(self) -> str: ...
2121
def to_yaml(self) -> str: ...
@@ -301,7 +301,7 @@ class LocoParams:
301301
mass_kilograms: Optional[float]
302302

303303
@classmethod
304-
def from_dict(cls, param_dict: Dict[str, float]) -> Self:
304+
def from_dict(cls, param_dict: Dict[str, float]) -> Self:
305305
"""
306306
Argument `param_dict` has keys matching attributes of class
307307
"""
@@ -738,7 +738,7 @@ class LinkPoint(SerdeAPI):
738738
link_idx: LinkIdx
739739

740740

741-
class PathResCoeff(SerdeAPI):
741+
class PathResCoeff(SerdeAPI):
742742
offset: float
743743
res_coeff: float
744744
res_net: float
@@ -790,7 +790,7 @@ class BrakingPoints(SerdeAPI):
790790
idx_curr: int
791791

792792

793-
class FricBrakeState(SerdeAPI):
793+
class FricBrakeState(SerdeAPI):
794794
i: int
795795
force_newtons: float
796796
force_max_curr_newtons: float
@@ -800,7 +800,7 @@ class FricBrakeStateHistoryVec(SerdeAPI):
800800
i: List[int]
801801
force_newtons: List[float]
802802
force_max_curr_newtons: List[float]
803-
803+
804804

805805
class FricBrake(SerdeAPI):
806806
force_max_newtons: float
@@ -983,6 +983,8 @@ class Heading(SerdeAPI):
983983
@classmethod
984984
def default(cls) -> Self: ...
985985

986+
class SpeedSet(SerdeAPI): ...
987+
# TODO: finish fleshing this out
986988

987989
def import_locations(filename: str) -> Dict[str, List[Location]]: ...
988990
def import_rail_vehicles(filename: str) -> Dict[str, RailVehicle]: ...
@@ -1097,4 +1099,4 @@ class TrainType(SerdeAPI):
10971099
Intermodal = altpy.TrainType.Intermodal,
10981100
HighSpeedPassenger = altpy.TrainType.HighSpeedPassenger,
10991101
TiltTrain = altpy.TrainType.TiltTrain,
1100-
Commuter = altpy.TrainType.Commuter,
1102+
Commuter = altpy.TrainType.Commuter,

rust/altrios-core/src/prelude.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ pub use crate::train::{
4444
};
4545

4646
pub use crate::track::{
47-
Elev, Heading, Link, LinkIdx, LinkPath, LinkPoint, Location, Network, TrainParams, TrainType,
47+
Elev, Heading, Link, LinkIdx, LinkPath, LinkPoint, Location, Network, SpeedSet, TrainParams,
48+
TrainType,
4849
};

rust/altrios-py/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! expose most structs, methods, and functions to Python.
33
44
use altrios_core::prelude::*;
5+
use altrios_core::track::SpeedSet;
56
pub use pyo3::exceptions::{
67
PyAttributeError, PyFileNotFoundError, PyIndexError, PyNotImplementedError, PyRuntimeError,
78
};
@@ -54,6 +55,7 @@ fn altrios_pyo3(_py: Python, m: &PyModule) -> PyResult<()> {
5455
m.add_class::<Location>()?;
5556
m.add_class::<Network>()?;
5657
m.add_class::<LinkPath>()?;
58+
m.add_class::<SpeedSet>()?;
5759

5860
m.add_class::<InitTrainState>()?;
5961
m.add_class::<TrainState>()?;

0 commit comments

Comments
 (0)