<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _space(self, hwr_obj, stroke, kind):
 """Do the interpolation of 'kind' for 'stroke'"""

        new_stroke = []
        stroke = sorted(stroke, key=lambda p: p['time'])

        x, y, t = [], [], []

        for point in stroke:
            x.append(point['x'])
            y.append(point['y'])
            t.append(point['time'])

        x, y = numpy.array(x), numpy.array(y)
        failed = False
        try:
            fx = interp1d(t, x, kind=kind)
            fy = interp1d(t, y, kind=kind)
        except Exception as e:  # pylint: disable=W0703
            if hwr_obj.raw_data_id is not None:
                logging.debug("spline failed for raw_data_id %i",
                              hwr_obj.raw_data_id)
            else:
                logging.debug("spline failed")
            logging.debug(e)
            failed = True

        tnew = numpy.linspace(t[0], t[-1], self.number)

        # linear interpolation fallback due to
        # https://github.com/scipy/scipy/issues/3868
        if failed:
            try:
                fx = interp1d(t, x, kind='linear')
                fy = interp1d(t, y, kind='linear')
                failed = False
            except Exception as e:
                logging.debug("len(stroke) = %i", len(stroke))
                logging.debug("len(x) = %i", len(x))
                logging.debug("len(y) = %i", len(y))
                logging.debug("stroke=%s", stroke)
                raise e

        for x, y, t in zip(fx(tnew), fy(tnew), tnew):
            new_stroke.append({'x': x, 'y': y, 'time': t})
        return new_stroke