From afba33205c24254e20aa59721c3155c1833d391a Mon Sep 17 00:00:00 2001 From: Robin Andersson Date: Wed, 13 Nov 2024 09:27:31 -0500 Subject: [PATCH] Changed for loop to another expression with better performance --- src/common/io.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/common/io.py b/src/common/io.py index 7b20c208..9e91ace0 100644 --- a/src/common/io.py +++ b/src/common/io.py @@ -1642,11 +1642,7 @@ def _find_max_trajectory_length(self, trajectories): among the set of continuous variables. We disregard parameters/constants since they are not stored with the same amount of data points as trajectories for continuous variables. """ - length = 0 - for var_name, trajectory in trajectories.items(): - if self.is_variable(var_name): # since we only consider continuous variables - length = max(length, len(trajectory.x)) - return length + return max([0] + [len(t.x) for v, t in trajectories.items() if self.is_variable(v)]) def _calculate_events_and_steps(self, name): if name in self._data_3: