summaryrefslogtreecommitdiff
path: root/numpy/lib/polynomial.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-06-15 12:04:39 -0600
committerCharles Harris <charlesr.harris@gmail.com>2016-06-15 12:04:39 -0600
commit330291ffcba6d00b6534bcf80107f3baea5b48a4 (patch)
treec66f20602935dde9c6a7609e2dea52faaaf28190 /numpy/lib/polynomial.py
parent37ee08dc9c7cbe0cf8a671c8cc73877d1a142ee1 (diff)
downloadnumpy-330291ffcba6d00b6534bcf80107f3baea5b48a4.tar.gz
TST: Test that polyfit raises if not enough data for cov estimate.
Also a slight refactoring of np.polyfit.
Diffstat (limited to 'numpy/lib/polynomial.py')
-rw-r--r--numpy/lib/polynomial.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index 741cbfa6a..d96b8969f 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -599,9 +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")
+ if len(x) <= order + 2:
+ raise ValueError("the number of data points must exceed order + 2 "
+ "for Bayesian estimate the covariance matrix")
fac = resids / (len(x) - order - 2.0)
if y.ndim == 1:
return c, Vbase * fac