Skip to content

Commit 1ffedbe

Browse files
committed
Added test to check if corr within bounds
1 parent d63760a commit 1ffedbe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/frame/methods/test_cov_corr.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,3 +485,15 @@ def test_corrwith_min_periods_boolean(self):
485485
result = df_bool.corrwith(ser_bool, min_periods=3)
486486
expected = Series([0.57735, 0.57735], index=["A", "B"])
487487
tm.assert_series_equal(result, expected)
488+
489+
def test_corr_within_bounds(self):
490+
df1 = DataFrame({"x": [0, 1], "y": [1.35951, 1.3595100000000007]})
491+
result1 = df1.corr().max().max()
492+
expected1 = 1.0
493+
tm.assert_equal(result1, expected1)
494+
495+
rng = np.random.default_rng(seed=42)
496+
df2 = DataFrame(rng.random(100, 4))
497+
corr_matrix = df2.corr()
498+
assert corr_matrix.min().min() >= -1.0
499+
assert corr_matrix.max().max() <= 1.0

0 commit comments

Comments
 (0)