# Buggy code
def validate(self):
    super(Rolling, self).validate()
    if not com.is_integer(self.window):
        raise ValueError("window must be an integer")


# Traceback (ValueError)
In [171]: s = pd.Series(range(3))

In [172]: s.rolling(-1) # doesn't raise
Out[172]: Rolling [window=-1,center=False,axis=0]

In [173]: s.rolling(-1).mean() # Odd, indirect error
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-173-cda5b8dd0812> in <module>()
----> 1 s.rolling(-1).mean()

/home/mike/modernpandas/local/lib/python2.7/site-packages/pandas/core/window.pyc in mean(self, **kwargs)
885     @Appender(_shared_docs['mean'])
886     def mean(self, **kwargs):
--> 887         return super(Rolling, self).mean(**kwargs)
888
889     @Substitution(name='rolling')

/home/mike/modernpandas/local/lib/python2.7/site-packages/pandas/core/window.pyc in mean(self, **kwargs)
651
652     def mean(self, **kwargs):
--> 653         return self._apply('roll_mean', 'mean', **kwargs)
654
655     _shared_docs['median'] = dedent("""

/home/mike/modernpandas/local/lib/python2.7/site-packages/pandas/core/window.pyc in _apply(self, func, name, window, center, check_minp, how, **kwargs)
558                 result = np.apply_along_axis(calc, self.axis, values)
559             else:
--> 560                 result = calc(values)
561
562             if center:

/home/mike/modernpandas/local/lib/python2.7/site-packages/pandas/core/window.pyc in calc(x)
553
554                 def calc(x):
--> 555                     return func(x, window, min_periods=self.min_periods)
556
557             if values.ndim > 1:

/home/mike/modernpandas/local/lib/python2.7/site-packages/pandas/core/window.pyc in func(arg, window, min_periods)
540                     # GH #12373: rolling functions error on float32 data
541                     return cfunc(com._ensure_float64(arg),
--> 542                                  window, minp, **kwargs)
543
544             # calculation function

pandas/algos.pyx in pandas.algos.roll_mean (pandas/algos.c:28921)()

pandas/algos.pyx in pandas.algos._check_minp (pandas/algos.c:19103)()

ValueError: min_periods must be >= 0

In [174]: pd.Series([]).rolling(-1).mean() # Never raises
Out[174]: Series([], dtype: float64)

In [175]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-71-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.1
nose: 1.3.7
pip: 8.0.2
setuptools: 20.1.1
Cython: 0.24
numpy: 1.11.0
scipy: 0.17.1
statsmodels: 0.6.1
xarray: None
IPython: 4.1.1
sphinx: None
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.4
blosc: 1.3.2
bottleneck: None
tables: 3.2.2
numexpr: 2.6.0
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None

# Fixed code
def validate(self):
    super(Rolling, self).validate()
    if not com.is_integer(self.window):
        raise ValueError("window must be an integer")
    elif self.window < 0:
        raise ValueError("window must be non-negative")