def __init__(self, obj, windows, min_periods=None, center=False):
        """
        Moving window object.

        Parameters
        ----------
        obj : Dataset or DataArray
            Object to window.
        windows : A mapping from a dimension name to window size
            dim : str
                Name of the dimension to create the rolling iterator
                along (e.g., `time`).
            window : int
                Size of the moving window.
        min_periods : int, default None
            Minimum number of observations in window required to have a value
            (otherwise result is NA). The default, None, is equivalent to
            setting min_periods equal to the size of the window.
        center : boolean, default False
            Set the labels at the center of the window.

        Returns
        -------
        rolling : type of input argument
        """

        if (has_bottleneck and
                (LooseVersion(bn.__version__) < LooseVersion('1.0'))):
            warnings.warn('xarray requires bottleneck version of 1.0 or '
                          'greater for rolling operations. Rolling '
                          'aggregation methods will use numpy instead'
                          'of bottleneck.')

        if len(windows) != 1:
            raise ValueError('exactly one dim/window should be provided')

        dim, window = next(iter(windows.items()))

        if window <= 0:
            raise ValueError('window must be > 0')

        self.obj = obj

        # attributes
        self.window = window
        self.min_periods = min_periods
        if min_periods is None:
            self._min_periods = window
        else:
            if min_periods <= 0:
                raise ValueError(
                    'min_periods must be greater than zero or None')

            self._min_periods = min_periods
        self.center = center
        self.dim = dim
def __init__ ( self , obj , windows , min_periods = None , center = False ) : if ( has_bottleneck and ( LooseVersion ( bn . __version__ ) < LooseVersion ( '1.0' ) ) ) : warnings . warn ( 'xarray requires bottleneck version of 1.0 or ' 'greater for rolling operations. Rolling ' 'aggregation methods will use numpy instead' 'of bottleneck.' ) if len ( windows ) != 1 : raise ValueError ( 'exactly one dim/window should be provided' ) dim , window = next ( iter ( windows . items ( ) ) ) if window <= 0 : raise ValueError ( 'window must be > 0' ) self . obj = obj self . window = window self . min_periods = min_periods if min_periods is None : self . _min_periods = window else : if min_periods <= 0 : raise ValueError ( 'min_periods must be greater than zero or None' ) self . _min_periods = min_periods self . center = center self . dim = dim
Moving window object.

        Parameters
        ----------
        obj : Dataset or DataArray
            Object to window.
        windows : A mapping from a dimension name to window size
            dim : str
                Name of the dimension to create the rolling iterator
                along (e.g., `time`).
            window : int
                Size of the moving window.
        min_periods : int, default None
            Minimum number of observations in window required to have a value
            (otherwise result is NA). The default, None, is equivalent to
            setting min_periods equal to the size of the window.
        center : boolean, default False
            Set the labels at the center of the window.

        Returns
        -------
        rolling : type of input argument