diff options
| author | Matteo Raso <mraso@uoguelph.ca> | 2022-08-24 04:44:05 -0400 |
|---|---|---|
| committer | Matteo Raso <mraso@uoguelph.ca> | 2022-08-24 04:44:05 -0400 |
| commit | 7a3066c39002404e5c0b7ff316317604ef3f603b (patch) | |
| tree | 8a2453358ff31a19777e429cb1caced8473a3239 /numpy/random | |
| parent | 50a74fb65fc752e77a2f9e9e2b7227629c2ba953 (diff) | |
| download | numpy-7a3066c39002404e5c0b7ff316317604ef3f603b.tar.gz | |
BUG: Made the error and warning messages for numpy.random.multivariate_normal more descriptive (closes #22140)
Issue #22140 says that numpy.random.multivariate_normal incorrectly warns that a non-symmetric positive-semidefinite matrix isn't positive-semidefinite. In the replies, there was some ambiguity over whether it was possible for a positive-semidefinite matrix to be non-symmetric, with reliable sources saying that symmetry is a common condition to add but not actually necessary. To solve this problem, two different members of the Numpy organization decided that the warning and error message "covariance is not positive-semidefinite" should be changed to "covariance is not symmetric positive-semidefinite". However, this change was never actually made yet.
Since this change only required me to change a few strings instead of actually changing the code, I've decided to skip the CI jobs.
[skip ci]
Diffstat (limited to 'numpy/random')
| -rw-r--r-- | numpy/random/_generator.pyx | 4 | ||||
| -rw-r--r-- | numpy/random/mtrand.pyx | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index da8ab64e2..6af101ed9 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -3736,10 +3736,10 @@ cdef class Generator: psd = not np.any(s < -tol) if not psd: if check_valid == 'warn': - warnings.warn("covariance is not positive-semidefinite.", + warnings.warn("covariance is not symmetric positive-semidefinite.", RuntimeWarning) else: - raise ValueError("covariance is not positive-semidefinite.") + raise ValueError("covariance is not symmetric positive-semidefinite.") if method == 'cholesky': _factor = l diff --git a/numpy/random/mtrand.pyx b/numpy/random/mtrand.pyx index 5672ed60b..7edd98351 100644 --- a/numpy/random/mtrand.pyx +++ b/numpy/random/mtrand.pyx @@ -4177,11 +4177,11 @@ cdef class RandomState: psd = np.allclose(np.dot(v.T * s, v), cov, rtol=tol, atol=tol) if not psd: if check_valid == 'warn': - warnings.warn("covariance is not positive-semidefinite.", + warnings.warn("covariance is not symmetric positive-semidefinite.", RuntimeWarning) else: raise ValueError( - "covariance is not positive-semidefinite.") + "covariance is not symmetric positive-semidefinite.") x = np.dot(x, np.sqrt(s)[:, None] * v) x += mean |
