Skip to content

Commit

Permalink
Improve the performance of ASE converter
Browse files Browse the repository at this point in the history
  • Loading branch information
MBartkowiakSTFC committed Mar 18, 2024
1 parent 1adaea5 commit 10754af
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions MDANSE/Src/MDANSE/Framework/Converters/ASE.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ def run_step(self, index):
try:
frame = self._input[index]
except TypeError:
frame = next(self._input)
else:
print("ASE using the slower way")
frame = read(self.configuration["trajectory_file"]["value"], index=index)
time = self._timeaxis[index]

Expand Down Expand Up @@ -195,15 +198,15 @@ def parse_first_step(self, mapping):
try:
self._input = ASETrajectory(self.configuration["trajectory_file"]["value"])
except:
self._input = iread(
self.configuration["trajectory_file"]["value"], index="[:]"
)
first_frame = read(self.configuration["trajectory_file"]["value"], index=0)
last_iterator = 0
generator = iread(self.configuration["trajectory_file"]["value"])
for _ in generator:
last_iterator += 1
generator.close()
self._input = iread(
self.configuration["trajectory_file"]["value"] # , index="[:]"
)
self._total_number_of_steps = last_iterator
else:
first_frame = self._input[0]
Expand Down

0 comments on commit 10754af

Please sign in to comment.