diff options
Diffstat (limited to 'numpy/lib/polynomial.py')
-rw-r--r-- | numpy/lib/polynomial.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 62f96f773..8c6f69cb0 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -548,6 +548,7 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False): Examples -------- + >>> import warnings >>> x = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]) >>> y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0]) >>> z = np.polyfit(x, y, 3) @@ -566,9 +567,10 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False): High-order polynomials may oscillate wildly: - >>> p30 = np.poly1d(np.polyfit(x, y, 30)) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter('ignore', np.RankWarning) + ... p30 = np.poly1d(np.polyfit(x, y, 30)) ... - >>> # RankWarning: Polyfit may be poorly conditioned... >>> p30(4) -0.80000000000000204 # may vary >>> p30(5) |