<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_range(self, bounds, keep_aspect=False):
 """Zoom to fit a box."""

        # a * (v0 + t) = -1
        # a * (v1 + t) = +1
        # =>
        # a * (v1 - v0) = 2
        bounds = np.asarray(bounds, dtype=np.float64)
        v0 = bounds[:2]
        v1 = bounds[2:]
        pan = -.5 * (v0 + v1)
        zoom = 2. / (v1 - v0)
        if keep_aspect:
            zoom = zoom.min() * np.ones(2)
        self.set_pan_zoom(pan=pan, zoom=zoom)