示例#1
0
def _check_window_params(data, window_length):
    """
    Check that a window of length `window_length` is well-defined on `data`.

    Parameters
    ----------
    data : np.ndarray[ndim=2]
        The array of data to check.
    window_length : int
        Length of the desired window.

    Returns
    -------
    None

    Raises
    ------
    WindowLengthNotPositive
        If window_length < 1.
    WindowLengthTooLong
        If window_length is greater than the number of rows in `data`.
    """
    if window_length < 1:
        raise WindowLengthNotPositive(window_length=window_length)

    if window_length > data.shape[0]:
        raise WindowLengthTooLong(
            nrows=data.shape[0],
            window_length=window_length,
        )
示例#2
0
 def _validate(self):
     super(PositiveWindowLengthMixin, self)._validate()
     if not self.windowed:
         raise WindowLengthNotPositive(window_length=self.window_length)
示例#3
0
文件: term.py 项目: mirizzi/zipline
 def _validate(self):
     if not self.windowed:
         raise WindowLengthNotPositive(window_length=self.window_length)
     return super(RequiredWindowLengthMixin, self)._validate()
示例#4
0
 def _validate(self):
     if self.windowed or self.window_length is NotSpecified:
         return super(RequiredWindowLengthMixin, self)._validate()
     raise WindowLengthNotPositive(window_length=self.window_length)