diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-05-23 22:02:13 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-05-23 22:02:13 +0000 |
commit | fc7afe0f14e31aa34e459952e4728bb4ec20daca (patch) | |
tree | 8c96e5662d85c76e4f14c925783762bde75c47fb /numpy | |
parent | 4ac790852f101dc36ffc50a5eeac4e0fe157b2d7 (diff) | |
download | numpy-fc7afe0f14e31aa34e459952e4728bb4ec20daca.tar.gz |
CHG: Use [] instead of 'default' to specify the default domain in
Chebyshev.fit and Polynomial.fit. Document the change from numpy 1.4.x.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/polynomial/polytemplate.py | 9 | ||||
-rw-r--r-- | numpy/polynomial/tests/test_chebyshev.py | 5 | ||||
-rw-r--r-- | numpy/polynomial/tests/test_polynomial.py | 5 |
3 files changed, 11 insertions, 8 deletions
diff --git a/numpy/polynomial/polytemplate.py b/numpy/polynomial/polytemplate.py index 706f22c2d..2a57a517f 100644 --- a/numpy/polynomial/polytemplate.py +++ b/numpy/polynomial/polytemplate.py @@ -565,11 +565,12 @@ class $name(pu.PolyBase) : passing in a 2D-array that contains one dataset per column. deg : int Degree of the fitting polynomial - domain : {None, [beg, end], 'default'}, optional + domain : {None, [], [beg, end]}, optional Domain to use for the returned $name instance. If ``None``, then a minimal domain that covers the points `x` is chosen. - If ``'default'`` the default domain ``$domain`` is used. The - default value is ``None``. + If ``[]`` the default domain ``$domain`` is used. The + default value is $domain in numpy 1.4.x and ``None`` in + numpy 2.0.0. The keyword value ``[]`` was added in numpy 2.0.0. rcond : float, optional Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be @@ -601,7 +602,7 @@ class $name(pu.PolyBase) : """ if domain is None : domain = pu.getdomain(x) - elif domain == 'default' : + elif domain == [] : domain = $domain xnew = pu.mapdomain(x, domain, $domain) res = ${nick}fit(xnew, y, deg, rcond=None, full=full) diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py index 5662d0362..17970ccc1 100644 --- a/numpy/polynomial/tests/test_chebyshev.py +++ b/numpy/polynomial/tests/test_chebyshev.py @@ -477,11 +477,12 @@ class TestChebyshevClass(TestCase) : assert_almost_equal(p.domain, [0,3]) # test that fit works in given domains - p = ch.Chebyshev.fit(x, y, 3, 'default') - assert_almost_equal(p(x), y) p = ch.Chebyshev.fit(x, y, 3, None) assert_almost_equal(p(x), y) assert_almost_equal(p.domain, [0,3]) + p = ch.Chebyshev.fit(x, y, 3, []) + assert_almost_equal(p(x), y) + assert_almost_equal(p.domain, [-1, 1]) def test_identity(self) : x = np.linspace(0,3) diff --git a/numpy/polynomial/tests/test_polynomial.py b/numpy/polynomial/tests/test_polynomial.py index 15525fcd8..c8edcd308 100644 --- a/numpy/polynomial/tests/test_polynomial.py +++ b/numpy/polynomial/tests/test_polynomial.py @@ -448,11 +448,12 @@ class TestPolynomialClass(TestCase) : assert_almost_equal(p.domain, [0,3]) # test that fit works in given domains - p = poly.Polynomial.fit(x, y, 3, 'default') - assert_almost_equal(p(x), y) p = poly.Polynomial.fit(x, y, 3, None) assert_almost_equal(p(x), y) assert_almost_equal(p.domain, [0,3]) + p = poly.Polynomial.fit(x, y, 3, []) + assert_almost_equal(p(x), y) + assert_almost_equal(p.domain, [-1, 1]) def test_identity(self) : x = np.linspace(0,3) |