<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def apply(self, window_length, samples=True, func1d=None):
 """ Runs any kind of function over a window. Args: window_length (int):
 the window length. Required. samples (bool):
 window length is in samples. Use False for a window length given in metres. func1d (function):
 a function that takes a 1D array and returns a scalar. Default: ``np.mean()``. Returns: Curve. """

        window_length /= 1 if samples else self.step
        if func1d is None:
            func1d = np.mean
        params = self.__dict__.copy()
        out = self._rolling_window(int(window_length), func1d)
        return Curve(out, params=params)