from hoomd.operation import _Updater
from hoomd.box import Box
from hoomd.parameterdicts import ParameterDict
from hoomd.typeconverter import OnlyType
from hoomd.variant import Variant
from hoomd.util import variant_preprocessing
from hoomd._hoomd import BoxResizeUpdater


class BoxResize(_Updater):
    def __init__(self, initial_box, final_box,
                 variant, trigger=1, scale_particles=True):
        params = ParameterDict(
            initial_box=OnlyType(Box), final_box=OnlyType(Box),
            variant=OnlyType(Variant, variant_preprocessing),
            scale_particles=bool)
        params['initial_box'] = initial_box
        params['final_box'] = final_box
        params['variant'] = variant
        params['trigger'] = trigger
        params['scale_particles'] = scale_particles
        self._param_dict.update(params)
        super().__init__(trigger)

    def attach(self, simulation):
        self._cpp_obj = BoxResizeUpdater(simulation.state._cpp_sys_def,
                                         self.initial_box, self.final_box,
                                         self.variant)
        super().attach(simulation)

    def get_box(self, timestep):
        if self.is_attached:
            timestep = int(timestep)
            if timestep < 0:
                raise ValueError("Timestep must be a non-negative integer.")
            return Box._from_cpp(self._cpp_obj.get_current_box(timestep))
        else:
            return None

@@ -294,16 +294,1297 @@
 dater):%0A
+    %22%22%22Resizes the box between an initial and final box.%0A%0A    When part of a :py:class:%60hoomd.Simulation%60 %60%60updater%60%60 list, this object%0A    will resize the box between the initial and final boxes passed. The behavior%0A    a linear interpolation between the initial and final boxes where the minimum%0A    of the variant represents initial box and the maximum represents the final%0A    box. All values between the minimum and maximum result in a box that is the%0A    interpolation of the three lengths and tilt factors of the initial and final%0A    box.%0A%0A    Note:%0A        The passed :py:class:%60hoomd.variant.Variant%60 must be well behaved (i.e.%0A        it must have a true minimum and maximum) or the behavior of the updater%0A        is undefined.%0A%0A    Args:%0A        initial_box (hoomd.box.Box): The box associated with the minimum of the%0A            passed variant.%0A        final_box (hoomd.box.Box): The box associated with the maximum of the%0A            passed variant.%0A        variant (hoomd.variant.Variant): A variant used to interpolate between%0A            the two boxes.%0A        trigger (hoomd.trigger.Trigger): The trigger to activate this updater.%0A        scale_particles (bool): Whether to scale particles to the new box%0A            dimensions when the box is resized.%0A%0A    %22%22%22%0A
     def 
@@ -2462,16 +2462,420 @@
 estep):%0A
+        %22%22%22Get the box for a given timestep.%0A%0A        This method allows for the querying of the box that would be used for a%0A        given timestep.%0A%0A        Args:%0A            timestep (int): The timestep to use for determining the resized%0A                box.%0A%0A        Returns:%0A            box (hoomd.box.Box): The box that would be used for resizing at the%0A                given timestep.%0A        %22%22%22%0A
         

Add documentation to BoxResize