Skip to content

Commit

Permalink
Add __reduce__() to box variants to allow pickling
Browse files Browse the repository at this point in the history
  • Loading branch information
tcmoore3 committed Mar 12, 2024
1 parent f66b49f commit 6c17eab
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hoomd/variant/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def __init__(self, initial_box, final_box, variant):
_hoomd.VectorVariantBoxInterpolate.__init__(self, box1._cpp_obj,
box2._cpp_obj, variant)

def __reduce__(self):
"""Reduce values to picklable format."""
return (type(self), (self.initial_box, self.final_box, self.variant))

@property
def initial_box(self):
"""hoomd.Box: The initial box."""
Expand Down Expand Up @@ -191,6 +195,11 @@ def __init__(self, initial_box, final_volume, t_start, t_ramp):
_hoomd.VectorVariantBoxInverseVolumeRamp.__init__(
self, box._cpp_obj, final_volume, t_start, t_ramp)

def __reduce__(self):
"""Reduce values to picklable format."""
return (type(self), (self.initial_box, self.final_volume, self.t_start,
self.t_ramp))

@property
def initial_box(self):
"""hoomd.Box: The initial box."""
Expand Down

0 comments on commit 6c17eab

Please sign in to comment.