Skip to content

Commit

Permalink
rename get_cyc_dict to to_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Carow authored and Kyle Carow committed Dec 1, 2023
1 parent c983054 commit b705e58
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 74 deletions.
14 changes: 7 additions & 7 deletions python/fastsim/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def __len__(self) -> int:
"return cycle length"
return len(self.time_s)

def get_cyc_dict(self) -> Dict[str, np.ndarray]:
def to_dict(self) -> Dict[str, np.ndarray]:
"""Returns cycle as dict rather than class instance."""
keys = STANDARD_CYCLE_KEYS

Expand Down Expand Up @@ -396,7 +396,7 @@ def to_microtrips(cycle, stop_speed_m__s=1e-6, keep_name=False):
Arguments:
----------
cycle: drive cycle converted to dictionary by cycle.get_cyc_dict()
cycle: drive cycle converted to dictionary by cycle.to_dict()
stop_speed_m__s: speed at which vehicle is considered stopped for trip
separation
keep_name: (optional) bool, if True and cycle contains "name", adds
Expand Down Expand Up @@ -469,8 +469,8 @@ def equals(c1, c2) -> bool:
Returns true if the two cycles are equal, false otherwise
Arguments:
----------
c1: cycle as dictionary from get_cyc_dict()
c2: cycle as dictionary from get_cyc_dict()
c1: cycle as dictionary from to_dict()
c2: cycle as dictionary from to_dict()
"""
if c1.keys() != c2.keys():
c2missing = set(c1.keys()) - set(c2.keys())
Expand Down Expand Up @@ -914,7 +914,7 @@ def extend_cycle(
RETURNS: fastsim.cycle.Cycle (or fastsimrust.RustCycle), the new cycle with stopped time appended
NOTE: additional time is rounded to the nearest second
"""
cyc0 = cyc.get_cyc_dict()
cyc0 = cyc.to_dict()
extra_time_s = absolute_time_s + float(int(round(time_fraction * cyc.time_s[-1])))
# Zero-velocity cycle segment so simulation doesn't end while moving
cyc_stop = resample(
Expand Down Expand Up @@ -952,13 +952,13 @@ def time_spent_moving(cycle):
blend_factor = max(0.0, min(1.0, blend_factor))
dist_and_tgt_speeds = []
# Split cycle into microtrips
microtrips = to_microtrips(cyc.get_cyc_dict())
microtrips = to_microtrips(cyc.to_dict())
dist_at_start_of_microtrip_m = 0.0
for mt in microtrips:
mt_cyc = Cycle.from_dict(mt)
mt_dist_m = sum(mt_cyc.dist_m)
mt_time_s = mt_cyc.time_s[-1] - mt_cyc.time_s[0]
mt_moving_time_s = time_spent_moving(mt_cyc.get_cyc_dict())
mt_moving_time_s = time_spent_moving(mt_cyc.to_dict())
mt_avg_spd_m_per_s = mt_dist_m / mt_time_s if mt_time_s > 0.0 else 0.0
mt_moving_avg_spd_m_per_s = mt_dist_m / mt_moving_time_s if mt_moving_time_s > 0.0 else 0.0
mt_target_spd_m_per_s = max(
Expand Down
8 changes: 4 additions & 4 deletions python/fastsim/demos/cav_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def maybe_str_to_bool(x, default=True):
#
# Here we set up an "automated cruise control" for a system
# that drives the average speed of the cycle.
cyc_udds = fsim.cycle.Cycle.from_file('udds').get_cyc_dict()
cyc_udds = fsim.cycle.Cycle.from_file('udds').to_dict()
cyc_stop = fsim.cycle.resample(
fsim.cycle.make_cycle([0.0, 200.0], [0.0, 0.0]),
new_dt=1.0,
Expand Down Expand Up @@ -116,7 +116,7 @@ def maybe_str_to_bool(x, default=True):
# the average speed of the microtrip assuming the vehicle
# is able to get the average speed per microtrip from some
# external source.
cyc_udds = fsim.cycle.Cycle.from_file('udds').get_cyc_dict()
cyc_udds = fsim.cycle.Cycle.from_file('udds').to_dict()
cyc_stop = fsim.cycle.resample(
fsim.cycle.make_cycle([0.0, 200.0], [0.0, 0.0]),
new_dt=1.0,
Expand All @@ -127,7 +127,7 @@ def maybe_str_to_bool(x, default=True):
veh = fsim.vehicle.Vehicle.from_vehdb(1).to_rust()
sd = fsim.simdrive.RustSimDrive(cyc, veh)
dist_and_avg_speeds = []
microtrips = fsim.cycle.to_microtrips(cyc.get_cyc_dict())
microtrips = fsim.cycle.to_microtrips(cyc.to_dict())
dist_at_start_of_microtrip_m = 0.0
for mt in microtrips:
mt_cyc = fsim.cycle.Cycle.from_dict(mt)
Expand Down Expand Up @@ -184,7 +184,7 @@ def maybe_str_to_bool(x, default=True):
# # Eco-Cruise and Eco-Approach running at the same time
#
# Here, we run an Eco-Cruise and Eco-Approach at the same time.
cyc_udds = fsim.cycle.Cycle.from_file('udds').get_cyc_dict()
cyc_udds = fsim.cycle.Cycle.from_file('udds').to_dict()
cyc_stop = fsim.cycle.resample(
fsim.cycle.make_cycle([0.0, 400.0], [0.0, 0.0]),
new_dt=1.0,
Expand Down
2 changes: 1 addition & 1 deletion python/fastsim/demos/cav_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def load_cycle(cyc_name: str, use_rust: bool=False) -> fastsim.cycle.Cycle:
if RESAMPLE_TO_1HZ:
raw_cycle = fastsim.cycle.Cycle.from_dict(
fastsim.cycle.resample(
raw_cycle.get_cyc_dict(),
raw_cycle.to_dict(),
new_dt=1.0,
hold_keys_next={'grade'},
)
Expand Down
22 changes: 11 additions & 11 deletions python/fastsim/demos/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def get_sim_drive_vec(
# %% generate micro-trip
t0 = time.perf_counter()
cyc = fsim.cycle.Cycle.from_file("udds")
microtrips = fsim.cycle.to_microtrips(cyc.get_cyc_dict())
microtrips = fsim.cycle.to_microtrips(cyc.to_dict())
cyc = fsim.cycle.Cycle.from_dict(microtrips[1])
print(f'Time to load cycle: {time.perf_counter() - t0:.2e} s')

Expand Down Expand Up @@ -681,7 +681,7 @@ def get_sim_drive_vec(
cyc1 = fsim.cycle.Cycle.from_file(
str(Path(fsim.simdrive.__file__).parent / 'resources/cycles/udds.csv'))
cyc2 = fsim.cycle.Cycle.from_file("us06")
cyc_combo = fsim.cycle.concat([cyc1.get_cyc_dict(), cyc2.get_cyc_dict()])
cyc_combo = fsim.cycle.concat([cyc1.to_dict(), cyc2.to_dict()])
cyc_combo = fsim.cycle.Cycle.from_dict(cyc_combo)
print(f'Time to load cycles: {time.perf_counter() - t0:.2e} s')

Expand Down Expand Up @@ -727,15 +727,15 @@ def get_sim_drive_vec(
cyc1 = fsim.cycle.Cycle.from_file("udds")
cyc2 = fsim.cycle.Cycle.from_file("us06")
print('Cycle 1 and 2 equal?')
print(fsim.cycle.equals(cyc1.get_cyc_dict(), cyc2.get_cyc_dict()))
print(fsim.cycle.equals(cyc1.to_dict(), cyc2.to_dict()))
cyc1 = fsim.cycle.Cycle.from_file("udds")
cyc2 = fsim.cycle.Cycle.from_file("udds")
print('Cycle 1 and 2 equal?')
print(fsim.cycle.equals(cyc1.get_cyc_dict(), cyc2.get_cyc_dict()))
cyc2dict = cyc2.get_cyc_dict()
print(fsim.cycle.equals(cyc1.to_dict(), cyc2.to_dict()))
cyc2dict = cyc2.to_dict()
cyc2dict['extra key'] = None
print('Cycle 1 and 2 equal?')
print(fsim.cycle.equals(cyc1.get_cyc_dict(), cyc2dict))
print(fsim.cycle.equals(cyc1.to_dict(), cyc2dict))
print(f'Time to load and compare cycles: {time.perf_counter() - t0:.2e} s')

# %% [markdown]
Expand All @@ -744,8 +744,8 @@ def get_sim_drive_vec(
# %%
t0 = time.perf_counter()
cyc = fsim.cycle.Cycle.from_file("udds")
cyc10Hz = fsim.cycle.Cycle.from_dict(fsim.cycle.resample(cyc.get_cyc_dict(), new_dt=0.1))
cyc10s = fsim.cycle.Cycle.from_dict(fsim.cycle.resample(cyc.get_cyc_dict(), new_dt=10))
cyc10Hz = fsim.cycle.Cycle.from_dict(fsim.cycle.resample(cyc.to_dict(), new_dt=0.1))
cyc10s = fsim.cycle.Cycle.from_dict(fsim.cycle.resample(cyc.to_dict(), new_dt=10))

plt.plot(cyc10Hz.time_s, cyc10Hz.mph, marker=',')
plt.plot(cyc10s.time_s, cyc10s.mph, marker=',')
Expand All @@ -772,9 +772,9 @@ def get_sim_drive_vec(
cyc_udds = fsim.cycle.Cycle.from_file("udds")
# Generate cycle with 0.1 s time steps
cyc_udds_10Hz = fsim.cycle.Cycle.from_dict(
fsim.cycle.resample(cyc_udds.get_cyc_dict(), new_dt=0.1))
fsim.cycle.resample(cyc_udds.to_dict(), new_dt=0.1))
cyc_us06 = fsim.cycle.Cycle.from_file("us06")
cyc_combo = fsim.cycle.concat([cyc_udds_10Hz.get_cyc_dict(), cyc_us06.get_cyc_dict()])
cyc_combo = fsim.cycle.concat([cyc_udds_10Hz.to_dict(), cyc_us06.to_dict()])
cyc_combo = fsim.cycle.resample(cyc_combo, new_dt=1)
cyc_combo = fsim.cycle.Cycle.from_dict(cyc_combo)
print(f'Time to load and concatenate cycles: {time.perf_counter() - t0:.2e} s')
Expand Down Expand Up @@ -826,7 +826,7 @@ def get_sim_drive_vec(
# %% generate micro-trip
t0 = time.perf_counter()
cyc = fsim.cycle.Cycle.from_file("udds")
cyc = fsim.cycle.clip_by_times(cyc.get_cyc_dict(), t_end=300)
cyc = fsim.cycle.clip_by_times(cyc.to_dict(), t_end=300)
cyc = fsim.cycle.Cycle.from_dict(cyc)
print(f'Time to load and clip cycle: {time.perf_counter() - t0:.2e} s')

Expand Down
16 changes: 8 additions & 8 deletions python/fastsim/demos/demo_eu_vehicle_wltp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def convention_eu_veh_wltp_fe_test():
wltp_med_cyc_3b = fsim.cycle.Cycle.from_file('wltc_class3_med3b.csv').to_rust()
wltp_high_cyc_3b = fsim.cycle.Cycle.from_file('wltc_class3_high3b.csv').to_rust()
wltp_extrahigh_cyc_3 = fsim.cycle.Cycle.from_file('wltc_class3_extra_high3.csv').to_rust()
cyc_wltp_combo = fsim.cycle.concat([wltp_low_cyc_3.get_cyc_dict(),
wltp_med_cyc_3b.get_cyc_dict(),
wltp_high_cyc_3b.get_cyc_dict(),
wltp_extrahigh_cyc_3.get_cyc_dict()]
cyc_wltp_combo = fsim.cycle.concat([wltp_low_cyc_3.to_dict(),
wltp_med_cyc_3b.to_dict(),
wltp_high_cyc_3b.to_dict(),
wltp_extrahigh_cyc_3.to_dict()]
)
cyc_wltp_combo = fsim.cycle.Cycle.from_dict(cyc_wltp_combo).to_rust()

Expand Down Expand Up @@ -60,10 +60,10 @@ def hybrid_eu_veh_wltp_fe_test():
wltp_high_cyc_3b_rust = wltp_high_cyc_3b.to_rust()
wltp_extrahigh_cyc_3 = fsim.cycle.Cycle.from_file('wltc_class3_extra_high3.csv')
wltp_extrahigh_cyc_3_rust = wltp_extrahigh_cyc_3.to_rust()
cyc_wltp_combined = fsim.cycle.concat([wltp_low_cyc_3.get_cyc_dict(),
wltp_med_cyc_3b.get_cyc_dict(),
wltp_high_cyc_3b.get_cyc_dict(),
wltp_extrahigh_cyc_3.get_cyc_dict()
cyc_wltp_combined = fsim.cycle.concat([wltp_low_cyc_3.to_dict(),
wltp_med_cyc_3b.to_dict(),
wltp_high_cyc_3b.to_dict(),
wltp_extrahigh_cyc_3.to_dict()
]
)
cyc_wltp_combined = fsim.cycle.Cycle.from_dict(cyc_wltp_combined)
Expand Down
4 changes: 2 additions & 2 deletions python/fastsim/demos/stop_start_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
# %%
t0 = time.time()
# cyc = cycle.Cycle.from_dict(cyc_dict=
# cycle.clip_by_times(cycle.Cycle.from_file("udds").get_cyc_dict(), 130))
cyc = cycle.Cycle.from_file('udds').get_cyc_dict()
# cycle.clip_by_times(cycle.Cycle.from_file("udds").to_dict(), 130))
cyc = cycle.Cycle.from_file('udds').to_dict()
cyc = cycle.Cycle.from_dict(cycle.clip_by_times(cyc, 130))
print(f"Elapsed time: {time.time() - t0:.3e} s")

Expand Down
2 changes: 1 addition & 1 deletion python/fastsim/demos/time_dilation_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

t0 = time.time()
cyc = cycle.Cycle.from_dict(cyc_dict=cycle.clip_by_times(
cycle.Cycle.from_file('longHaulDriveCycle').get_cyc_dict(),
cycle.Cycle.from_file('longHaulDriveCycle').to_dict(),
t_end=18_000, t_start=1_800))
print('Time to load cycle file: {:.3f} s'.format(time.time() - t0))

Expand Down
8 changes: 4 additions & 4 deletions python/fastsim/demos/wltc_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def mpgge_to_litersPer100km(mpgge):
# Generate combined cycle
cyc_combined_dict = fastsim.cycle.concat(
[
cyc_low.get_cyc_dict(),
cyc_med.get_cyc_dict(),
cyc_high.get_cyc_dict(),
cyc_extrahigh.get_cyc_dict(),
cyc_low.to_dict(),
cyc_med.to_dict(),
cyc_high.to_dict(),
cyc_extrahigh.to_dict(),
]
)
cyc = fastsim.cycle.Cycle.from_dict(cyc_combined_dict)
Expand Down
2 changes: 1 addition & 1 deletion python/fastsim/fastsimrust.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class RustCycle(SerdeAPI):
def calc_distance_to_next_stop_from(self, distance_m: float) -> float:
...

def get_cyc_dict(self) -> Dict[str, List[float]]:
def to_dict(self) -> Dict[str, List[float]]:
"""Return a HashMap representing the cycle"""
...

Expand Down
42 changes: 21 additions & 21 deletions python/fastsim/tests/test_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ def test_load_dict(self):
cyc_from_dict = cycle.Cycle.from_dict(cyc_dict)

self.assertTrue((
pd.DataFrame(cyc.get_cyc_dict()) ==
pd.DataFrame(cyc_from_dict.get_cyc_dict())).all().all()
pd.DataFrame(cyc.to_dict()) ==
pd.DataFrame(cyc_from_dict.to_dict())).all().all()
)

def test_that_udds_has_18_microtrips(self):
"Check that the number of microtrips equals expected"
cyc = cycle.Cycle.from_file("udds")
microtrips = cycle.to_microtrips(cyc.get_cyc_dict())
microtrips = cycle.to_microtrips(cyc.to_dict())
expected_number_of_microtrips = 18
actual_number_of_microtrips = len(microtrips)
self.assertTrue(
Expand All @@ -109,7 +109,7 @@ def test_that_udds_has_18_microtrips(self):
def test_roundtrip_of_microtrip_and_concat(self):
"A cycle split into microtrips and concatenated back together should equal the original"
cyc = cycle.Cycle.from_file("udds")
cyc_dict = cyc.get_cyc_dict()
cyc_dict = cyc.to_dict()
microtrips = cycle.to_microtrips(cyc_dict)
# NOTE: specifying the name for concat is required to get the same keys
reconstituted_cycle = cycle.concat(microtrips, name=cyc_dict["name"])
Expand All @@ -119,7 +119,7 @@ def test_roundtrip_of_microtrip_and_concat(self):
def test_roundtrip_of_microtrip_and_concat_using_keep_name_arg(self):
"A cycle split into microtrips and concatenated back together should equal the original"
cyc = cycle.Cycle.from_file("udds")
cyc_dict = cyc.get_cyc_dict()
cyc_dict = cyc.to_dict()
microtrips = cycle.to_microtrips(cyc_dict, keep_name=True)
# NOTE: specifying the name for concat is required to get the same keys
reconstituted_cycle = cycle.concat(microtrips, name=cyc_dict["name"])
Expand All @@ -129,19 +129,19 @@ def test_roundtrip_of_microtrip_and_concat_using_keep_name_arg(self):
def test_set_from_dict_for_a_microtrip(self):
"Test splitting into microtrips and setting is as expected"
cyc = cycle.Cycle.from_file("udds")
cyc_dict = cyc.get_cyc_dict()
cyc_dict = cyc.to_dict()
microtrips = cycle.to_microtrips(cyc_dict, keep_name=True)
cyc = cycle.Cycle.from_dict(microtrips[1])
mt_dict = cyc.get_cyc_dict()
mt_dict = cyc.to_dict()
(are_equal, issues) = dicts_are_equal(microtrips[1], mt_dict, "first_microtrip", "microtrip_via_set_from_dict")
self.assertTrue(are_equal, "; ".join(issues))

def test_duration_of_concatenated_cycles_is_the_sum_of_the_components(self):
"Test that two cycles concatenated have the same duration as the sum of the constituents"
cyc1 =cycle.Cycle.from_file('udds')
cyc2 =cycle.Cycle.from_file('us06')
cyc_concat12 = cycle.concat([cyc1.get_cyc_dict(), cyc2.get_cyc_dict()])
cyc_concat21 = cycle.concat([cyc2.get_cyc_dict(), cyc1.get_cyc_dict()])
cyc_concat12 = cycle.concat([cyc1.to_dict(), cyc2.to_dict()])
cyc_concat21 = cycle.concat([cyc2.to_dict(), cyc1.to_dict()])
cyc12 = cycle.Cycle.from_dict(cyc_dict=cyc_concat12)
cyc21 = cycle.Cycle.from_dict(cyc_dict=cyc_concat21)
self.assertEqual(cyc_concat12["time_s"][-1], cyc_concat21["time_s"][-1])
Expand All @@ -157,19 +157,19 @@ def test_cycle_equality(self):
"Test structural equality of driving cycles"
udds = cycle.Cycle.from_file("udds")
us06 = cycle.Cycle.from_file("us06")
self.assertFalse(cycle.equals(udds.get_cyc_dict(), us06.get_cyc_dict()))
self.assertFalse(cycle.equals(udds.to_dict(), us06.to_dict()))
udds_2 = cycle.Cycle.from_file("udds")
self.assertTrue(cycle.equals(udds.get_cyc_dict(), udds_2.get_cyc_dict()))
cyc2dict = udds_2.get_cyc_dict()
self.assertTrue(cycle.equals(udds.to_dict(), udds_2.to_dict()))
cyc2dict = udds_2.to_dict()
cyc2dict['extra key'] = None
self.assertFalse(cycle.equals(udds.get_cyc_dict(), cyc2dict))
self.assertFalse(cycle.equals(udds.to_dict(), cyc2dict))

def test_that_cycle_resampling_works_as_expected(self):
"Test resampling the values of a cycle"
for cycle_name in ["udds", "us06", "hwfet", "longHaulDriveCycle"]:
cyc = cycle.Cycle.from_file(cycle_name)
cyc_at_dt0_1 = cycle.Cycle.from_dict(cycle.resample(cyc.get_cyc_dict(), new_dt=0.1))
cyc_at_dt10 = cycle.Cycle.from_dict(cycle.resample(cyc.get_cyc_dict(), new_dt=10))
cyc_at_dt0_1 = cycle.Cycle.from_dict(cycle.resample(cyc.to_dict(), new_dt=0.1))
cyc_at_dt10 = cycle.Cycle.from_dict(cycle.resample(cyc.to_dict(), new_dt=10))
msg = f"issue for {cycle_name}, {len(cyc.time_s)} points, duration {cyc.time_s[-1]}"
expected_num_at_dt0_1 = 10 * len(cyc.time_s) - 9
self.assertEqual(len(cyc_at_dt0_1.time_s), expected_num_at_dt0_1, msg)
Expand All @@ -186,12 +186,12 @@ def test_resampling_and_concatenating_cycles(self):
"Test that concatenating cycles at different sampling rates works as expected"
udds = cycle.Cycle.from_file("udds")
udds_10Hz = cycle.Cycle.from_dict(
cyc_dict=cycle.resample(udds.get_cyc_dict(), new_dt=0.1))
cyc_dict=cycle.resample(udds.to_dict(), new_dt=0.1))
us06 = cycle.Cycle.from_file("us06")
combo_resampled = cycle.resample(
cycle.concat([udds_10Hz.get_cyc_dict(), us06.get_cyc_dict()]),
cycle.concat([udds_10Hz.to_dict(), us06.to_dict()]),
new_dt=1)
combo = cycle.concat([udds.get_cyc_dict(), us06.get_cyc_dict()])
combo = cycle.concat([udds.to_dict(), us06.to_dict()])
self.assertTrue(cycle.equals(combo, combo_resampled))

def test_resampling_with_hold_keys(self):
Expand All @@ -210,7 +210,7 @@ def test_resampling_with_hold_keys(self):
def test_that_resampling_preserves_total_distance_traveled_using_rate_keys(self):
"Distance traveled before and after resampling should be the same when rate_keys are used"
for cycle_name in ['udds', 'us06', 'hwfet', 'longHaulDriveCycle']:
the_cyc = cycle.Cycle.from_file(cycle_name).get_cyc_dict()
the_cyc = cycle.Cycle.from_file(cycle_name).to_dict()
# DOWNSAMPLING
new_dt_s = 10.0
cyc_at_0_1hz = cycle.resample(the_cyc, new_dt=new_dt_s)
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_that_resampling_preserves_total_distance_traveled_using_rate_keys(self)

def test_clip_by_times(self):
"Test that clipping by times works as expected"
udds = cycle.Cycle.from_file("udds").get_cyc_dict()
udds = cycle.Cycle.from_file("udds").to_dict()
udds_start = cycle.clip_by_times(udds, t_end=300)
udds_end = cycle.clip_by_times(udds, t_end=udds["time_s"][-1], t_start=300)
self.assertTrue(udds_start['time_s'][-1] == 300.0)
Expand Down Expand Up @@ -305,7 +305,7 @@ def test_that_copy_creates_idential_structures(self):
"Checks that copy methods produce identical cycles"
udds = cycle.Cycle.from_file('udds')
another_udds = cycle.copy_cycle(udds)
self.assertTrue(udds.get_cyc_dict(), another_udds.get_cyc_dict())
self.assertTrue(udds.to_dict(), another_udds.to_dict())

def test_make_cycle(self):
"Check that make_cycle works as expected"
Expand Down
6 changes: 3 additions & 3 deletions python/fastsim/tests/test_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def use_simdrive_post(use_rust=False, verbose=False):
# generate micro-trip
t0 = time.perf_counter()
cyc = fsim.cycle.Cycle.from_file("udds")
microtrips = fsim.cycle.to_microtrips(cyc.get_cyc_dict())
microtrips = fsim.cycle.to_microtrips(cyc.to_dict())
cyc = fsim.cycle.Cycle.from_dict(microtrips[1])
if verbose:
print(f'Time to load cycle: {time.perf_counter() - t0:.2e} s')
Expand Down Expand Up @@ -278,8 +278,8 @@ def test_using_simdrive_post(self):
def test_cycle_to_dict(self):
py_cyc = fsim.cycle.Cycle.from_file('udds')
ru_cyc = py_cyc.to_rust()
py_dict = py_cyc.get_cyc_dict()
ru_dict = ru_cyc.get_cyc_dict()
py_dict = py_cyc.to_dict()
ru_dict = ru_cyc.to_dict()
py_keys = {k for k in py_dict}
ru_keys = {k for k in ru_dict}
ru_keys.add("name") # Rust doesn't provide 'name'
Expand Down
Loading

0 comments on commit b705e58

Please sign in to comment.