Skip to content

Commit

Permalink
Changed for loop to another expression with better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
modelonrobinandersson committed Nov 13, 2024
1 parent 51228a7 commit afba332
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/common/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit afba332

Please sign in to comment.