MCPcopy
hub / github.com/pandas-dev/pandas / test_corr_sanity

Function test_corr_sanity

pandas/tests/window/test_pairwise.py:122–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120
121
122def 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
145def test_rolling_cov_diff_length():

Callers

nothing calls this directly

Calls 5

DataFrameClass · 0.90
absMethod · 0.80
arrayMethod · 0.45
corrMethod · 0.45
rollingMethod · 0.45

Tested by

no test coverage detected