Skip to content

Commit

Permalink
clip r values (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
remrama authored Feb 21, 2023
1 parent f663e4e commit 7b652dc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pingouin/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,10 @@ def corr(x, y, alternative="two-sided", method="pearson", **kwargs):
n_outliers = sum(outliers) if "outliers" in locals() else 0
n_clean = n - n_outliers

# Rounding errors caused an r value marginally beyond 1
if abs(r) > 1 and np.isclose(abs(r), 1):
r = np.clip(r, -1, 1)

# Compute the parametric 95% confidence interval and power
if abs(r) == 1:
ci = [r, r]
Expand Down

0 comments on commit 7b652dc

Please sign in to comment.