Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
--- CHANGELOG ---
--- PyFMI-FUTURE ---
* Fixed an issue for dynamic_diagnostics, where failures to evaluate the Jacobian would result in invalid XML.
* Fixed a race-condition in using ResultDymolaBinary.get_variables_data().

--- PyFMI-2.17.1 ---
* Fixed compilation issue with Cython 3.1.
Expand Down
8 changes: 5 additions & 3 deletions src/common/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,8 @@ def _read_trajectory_data(self, data_index, read_diag_data, start_index = 0, sto
note that 'read_diag_data' is a boolean used when this function is invoked for
diagnostic variables.
"""
self._verify_file_data()
# Assume self._verify_file_data() was called before, since
# we typically have 2 calls to _read_trajectory_data(...); time & data

file_position = int(self._data_2_info["file_position"])
sizeof_type = int(self._data_2_info["sizeof_type"])
Expand Down Expand Up @@ -1442,7 +1443,7 @@ def _read_trajectory_data(self, data_index, read_diag_data, start_index = 0, sto

return data

def _get_interpolated_trajectory(self, data_index: int, start_index: int = 0, stop_index: int = None) -> Trajectory:
def _get_interpolated_trajectory(self, data_index: int, start_index: int = 0, stop_index: int | None = None) -> Trajectory:
""" Returns an interpolated trajectory for variable of corresponding index 'data_index'. """
self._verify_file_data()

Expand All @@ -1455,7 +1456,8 @@ def _get_interpolated_trajectory(self, data_index: int, start_index: int = 0, st
time_vector = self._read_trajectory_data(0, False, start_index, stop_index)
data = self._read_trajectory_data(data_index, False, start_index, stop_index)
Comment thread
PeterMeisrimelModelon marked this conversation as resolved.

f = scipy.interpolate.interp1d(time_vector, data, fill_value="extrapolate")
n = min(len(time_vector), len(data)) # safety for reading wiith allow_file_updates = True
f = scipy.interpolate.interp1d(time_vector[:n], data[:n], fill_value = "extrapolate")

# note that we dont need to slice here because diag_time_vector is already sliced accordingly
self._data_2[data_index] = f(diag_time_vector)
Expand Down