diff --git a/docs/changelog.rst b/docs/changelog.rst index b93a03d6..9b27e865 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,6 +3,15 @@ What's new ########## +v0.3.11 (unreleased) +-------------------- + +**Bugfixes** + +a. Passing a wrong ``tail`` argument to :py:func:`pingouin.correlation.corr` now *always* raises an error (see `PR 160 `_). + In previous versions of ``pingouin``, using any ``method`` other than ``"pearson"`` and a wrong ``tail`` argument such as ``"two-tailed"`` or ``"both"`` + (instead of the correct ``"two-sided"``) may have resulted in silently returning a one-sided p-value. + v0.3.10 (February 2021) ----------------------- diff --git a/pingouin/correlation.py b/pingouin/correlation.py index 12a13e15..3e16cc3d 100644 --- a/pingouin/correlation.py +++ b/pingouin/correlation.py @@ -508,6 +508,8 @@ def corr(x, y, tail='two-sided', method='pearson', **kwargs): y = np.asarray(y) assert x.ndim == y.ndim == 1, 'x and y must be 1D array.' assert x.size == y.size, 'x and y must have the same length.' + _msg = 'tail must be "two-sided" or "one-sided".' + assert tail in ['two-sided', 'one-sided'], _msg # Remove rows with missing values x, y = remove_na(x, y, paired=True) @@ -529,7 +531,7 @@ def corr(x, y, tail='two-sided', method='pearson', **kwargs): elif method == 'skipped': r, pval, outliers = skipped(x, y, **kwargs) else: - raise ValueError('Method not recognized.') + raise ValueError(f'Method "{method}" not recognized.') if np.isnan(r): # Correlation failed -- new in version v0.3.4, instead of raising an