Skip to content

Update 7672, BUG: Make sure we don't divide by zero #7747

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

Merged
merged 2 commits into from
Jun 15, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG: Make sure we don't divide by zero in np.polyfit.
This should fix the issue discussed at
https://mail.scipy.org/pipermail/numpy-discussion/2013-July/067076.html

Without the ValueError added here, polyfit can (and does) return
negative or nan variances with no warning.
  • Loading branch information
daschaich authored and charris committed Jun 15, 2016
commit 37ee08dc9c7cbe0cf8a671c8cc73877d1a142ee1
3 changes: 3 additions & 0 deletions numpy/lib/polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,9 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False):
# it is included here because the covariance of Multivariate Student-T
# (which is implied by a Bayesian uncertainty analysis) includes it.
# Plus, it gives a slightly more conservative estimate of uncertainty.
if (len(x) - order - 2.0) < 1:
raise ValueError("the number of data points must exceed "
"the degree + 3 for covariance matrix")
fac = resids / (len(x) - order - 2.0)
if y.ndim == 1:
return c, Vbase * fac
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy