Skip to content

Commit

Permalink
Read from pickle.
Browse files Browse the repository at this point in the history
  • Loading branch information
rousseab committed Jun 10, 2024
1 parent c613948 commit e30e358
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crystal_diffusion/utils/sample_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ def record_ode_solution(self, times: torch.Tensor, relative_coordinates: torch.T
self.data['status'].append(status)
self.data['relative_coordinates'].append(relative_coordinates)

@staticmethod
def read_from_pickle(path_to_pickle: str):
"""Read from pickle."""
with open(path_to_pickle, 'rb') as fd:
sample_trajectory = ODESampleTrajectory()
sample_trajectory.data = torch.load(fd, map_location=torch.device('cpu'))
return sample_trajectory


class NoOpODESampleTrajectory(ODESampleTrajectory):
"""A sample trajectory object that performs no operation."""
Expand Down

0 comments on commit e30e358

Please sign in to comment.