-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Description
I have an array of non-negative numbers, that when used with rolling_sum
or rolling_mean
produce an output array that has a small negative number in it.
The test looks like this:
import numpy as np
import pandas
data = np.load('data.npy')
assert all(data >= 0)
sums = pandas.rolling_sum(data, 2, min_periods=1)
zero = np.where(sums < 0)[0]
assert len(zero) == 0, zero
mean = pandas.rolling_mean(data, 2, min_periods=1)
zero = np.where(mean < 0)[0]
assert len(zero) == 0, zero
It requires a small binary array to reproduce, because of the floating point numbers (so I created a gist: https://gist.github.com/3948013).
You can run the test case:
$ git clone git://gist.github.com/3948013.git
$ cd 3948013
$ python test.py
I made sure this bug affects the most current version of Pandas:
>>> import pandas
>>> pandas.__version__
'0.9.1.dev-8cd93d3'
>>> import numpy
>>> numpy.__version__
'1.7.0b2'