| 120 | |
| 121 | |
| 122 | def test_corr_sanity(): |
| 123 | # GH 3155 |
| 124 | df = DataFrame( |
| 125 | np.array( |
| 126 | [ |
| 127 | [0.87024726, 0.18505595], |
| 128 | [0.64355431, 0.3091617], |
| 129 | [0.92372966, 0.50552513], |
| 130 | [0.00203756, 0.04520709], |
| 131 | [0.84780328, 0.33394331], |
| 132 | [0.78369152, 0.63919667], |
| 133 | ] |
| 134 | ) |
| 135 | ) |
| 136 | |
| 137 | res = df[0].rolling(5, center=True).corr(df[1]) |
| 138 | assert all(np.abs(np.nan_to_num(x)) <= 1 for x in res) |
| 139 | |
| 140 | df = DataFrame(np.random.default_rng(2).random((30, 2))) |
| 141 | res = df[0].rolling(5, center=True).corr(df[1]) |
| 142 | assert all(np.abs(np.nan_to_num(x)) <= 1 for x in res) |
| 143 | |
| 144 | |
| 145 | def test_rolling_cov_diff_length(): |