Skip to content

Commit

Permalink
fixed plotting problems
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Jan 15, 2025
1 parent 10a5f96 commit 93899c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions python/fastsim/demos/demo_hev.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ def plot_fc_energy() -> Tuple[Figure, Axes]:
label="fuel",
linestyle=baselinestyles[1]
)
ax[1].set_ylim((-sd.veh.fc.state.energy_fuel_joules * 1e-6 * 0.1,
sd.veh.fc.state.energy_fuel_joules * 1e-6 * 0.1))
ax[1].set_ylim((-sd_dict["veh"]["pt_type"]["HybridElectricVehicle"]["fc"]["state"]["energy_fuel_joules"] * 1e-6 * 0.1,
sd_dict["veh"]["pt_type"]["HybridElectricVehicle"]["fc"]["state"]["energy_fuel_joules"] * 1e-6 * 0.1))
ax[1].set_ylabel("FC Energy\nDelta (f3-f2) [MJ]\n+/- 10% Range")
ax[1].legend()

Expand Down
9 changes: 2 additions & 7 deletions python/fastsim/tests/test_serde.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import numpy as np
from pathlib import Path
import time
import json
import msgpack
import os
from typing import Tuple
import fastsim as fsim

def get_solved_sd():
Expand Down Expand Up @@ -45,12 +39,13 @@ def test_pydict():

t0 = time.perf_counter_ns()
sd_dict_json = sd.to_pydict(flatten=False, data_fmt="json")
sd_json = fsim.SimDrive.from_pydict(sd_dict_json, data_fmt="json")
_sd_json = fsim.SimDrive.from_pydict(sd_dict_json, data_fmt="json")
t1 = time.perf_counter_ns()
t_json = t1 - t0
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 sd_msg == sd
assert sd_yaml == sd
# TODO: uncomment and investigate
Expand Down

0 comments on commit 93899c1

Please sign in to comment.