Skip to content

Commit a626014

Browse files
author
y-p
committed
TST: added rolling_corr test with cener=True GH3155
Conflicts: pandas/stats/tests/test_moments.py
1 parent b6b6023 commit a626014

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pandas/stats/tests/test_moments.py

+22
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,28 @@ def test_flex_binary_moment(self):
583583
# don't blow the stack
584584
self.assertRaises(ValueError, mom._flex_binary_moment,5,6,None)
585585

586+
def test_corr_sanity(self):
587+
#GH 3155
588+
df = DataFrame(
589+
np.array(
590+
[[ 0.87024726, 0.18505595],
591+
[ 0.64355431, 0.3091617 ],
592+
[ 0.92372966, 0.50552513],
593+
[ 0.00203756, 0.04520709],
594+
[ 0.84780328, 0.33394331],
595+
[ 0.78369152, 0.63919667]])
596+
)
597+
598+
res = mom.rolling_corr(df[0],df[1],5,center=True)
599+
self.assertTrue(all([np.abs(np.nan_to_num(x)) <=1 for x in res]))
600+
601+
# and some fuzzing
602+
for i in range(10):
603+
df = DataFrame(np.random.rand(30,2))
604+
res = mom.rolling_corr(df[0],df[1],5,center=True)
605+
print( res)
606+
self.assertTrue(all([np.abs(np.nan_to_num(x)) <=1 for x in res]))
607+
586608
def test_flex_binary_frame(self):
587609
def _check(method):
588610
series = self.frame[1]

0 commit comments

Comments
 (0)