-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kdeplot raising LinAlgError("singular matrix") instead of warning #2762
Comments
Here is what seaborn is doing import math
print(observation_variance := df["a"].var(ddof=1))
print(math.isclose(observation_variance, 0) )
|
I don’t recall if there’s a reason this does a proactive check rather than catching the error, but that may be easier. |
* Improve robustness to numerical errors in kdeplot Closes #2762 * Avoid finally block for Python 3.7 compat * Try to catch another edge case in tests
Hi, I was wondering if like it is defined here, I stumbled upon this for the following example: I am using |
Example code:
seaborn version 0.11.2
python version 3.8.12
Error:
numpy.linalg.LinAlgError: singular matrix
Expected:
UserWarning: Dataset has 0 variance; skipping density estimate. Pass 'warn_singular=False' to disable this warning.
I tried other types of singular matrixes and the singular warning implemented in 0.11.2 work as expected. (for example:
pd.DataFrame({'a': [0]*10})
orpd.DataFrame({'a': [0]})
)The problem seem to arise for particular floats. I tried other big floats and changed the value slightly resulting in different outcome.
Another interesting sequence:
pd.DataFrame({'a': [1929245168.06679]*18})
-> errorpd.DataFrame({'a': [1929245160.06679]*18})
-> errorpd.DataFrame({'a': [1929245100.06679]*18})
-> no error and no warning (singular_warn is True)The text was updated successfully, but these errors were encountered: