Skip to content

Commit

Permalink
Added verification of get_variables_data
Browse files Browse the repository at this point in the history
  • Loading branch information
modelonrobinandersson committed Feb 4, 2025
1 parent 6787a44 commit 3d1db1f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1956,22 +1956,31 @@ def test_mixes_get_variable_s_data(self):

def test_cpu_time(self):
""" Verify the cumulative CPU time trajectory is never decreasing. """
fmu = Dummy_FMUModelME2([], os.path.join(file_path, "files", "FMUs", "XML", "ME2.0", "bouncingBall.fmu"), _connect_dll=False)
fmu = Dummy_FMUModelME2(
[],
os.path.join(file_path, "files", "FMUs", "XML", "ME2.0", "bouncingBall.fmu"), _connect_dll=False
)
opts = fmu.simulate_options()
opts['dynamic_diagnostics'] = True
opts["result_file_name"] = "TestCPUTime.mat"
res = fmu.simulate(options = opts)

rdb = ResultDymolaBinary(opts["result_file_name"])
cpu_time = rdb.get_variable_data(f"{DIAGNOSTICS_PREFIX}cpu_time").x

cpu_time_2, _ = rdb.get_variables_data([f"{DIAGNOSTICS_PREFIX}cpu_time"])
cpu_time_2 = cpu_time_2[f"{DIAGNOSTICS_PREFIX}cpu_time"].x
first_value = -1 # initialize to any negative value since the first cpu_time value is 0.0

# Test that the data is never decreasing (since we return it using numpy cumulative sum)
for value in cpu_time:
assert value >= first_value
first_value = value

first_value = -1
for value in cpu_time_2:
assert value >= first_value
first_value = value

@pytest.mark.assimulo
class TestFileSizeLimit:
def _setup(self, result_type, result_file_name="", fmi_type="me"):
Expand Down

0 comments on commit 3d1db1f

Please sign in to comment.