Skip to content

Commit

Permalink
[utils.str_and_dict.iterate_and_inform_lambdas] replace list comprehe…
Browse files Browse the repository at this point in the history
…nsion with generator, much less memory usage (overdue TODO)
  • Loading branch information
gph82 committed Apr 1, 2024
1 parent 57151e2 commit 00cfc1e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mdciao/utils/str_and_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,7 @@ def iterate_and_inform_lambdas(ixtc,chunksize, stride=1, top=None):
"""
if isinstance(ixtc, _md.Trajectory):
# TODO it's time to use yield here, this is killing performance
iterate = lambda ixtc: [ixtc[idxs] for idxs in re_warp(_np.arange(ixtc.n_frames)[::stride], chunksize)]
iterate = lambda ixtc: (ixtc[idxs] for idxs in re_warp(_np.arange(ixtc.n_frames)[::stride], chunksize))
inform = lambda ixtc, traj_idx, chunk_idx, running_f: \
print("Streaming over trajectory object nr. %3u (%6u frames, %6u with stride %2u) in chunks of "
"%3u frames. Now at chunk nr %4u, frames so far %6u" %
Expand Down

0 comments on commit 00cfc1e

Please sign in to comment.