Python numpy.polynomial.polynomial.polyval() Examples
The following are 30
code examples of numpy.polynomial.polynomial.polyval().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy.polynomial.polynomial
, or try the search function
.
Example #1
Source File: test_chebyshev.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def test_chebval(self): #check empty input assert_equal(cheb.chebval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Tlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = cheb.chebval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(cheb.chebval(x, [1]).shape, dims) assert_equal(cheb.chebval(x, [1, 0]).shape, dims) assert_equal(cheb.chebval(x, [1, 0, 0]).shape, dims)
Example #2
Source File: test_chebyshev.py From ImageFusion with MIT License | 6 votes |
def test_chebval(self): #check empty input assert_equal(cheb.chebval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Tlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = cheb.chebval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(cheb.chebval(x, [1]).shape, dims) assert_equal(cheb.chebval(x, [1, 0]).shape, dims) assert_equal(cheb.chebval(x, [1, 0, 0]).shape, dims)
Example #3
Source File: test_chebyshev.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_chebval(self): #check empty input assert_equal(cheb.chebval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Tlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = cheb.chebval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(cheb.chebval(x, [1]).shape, dims) assert_equal(cheb.chebval(x, [1, 0]).shape, dims) assert_equal(cheb.chebval(x, [1, 0, 0]).shape, dims)
Example #4
Source File: test_laguerre.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_lagval(self): #check empty input assert_equal(lag.lagval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Llist] for i in range(7): msg = "At i=%d" % i tgt = y[i] res = lag.lagval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(lag.lagval(x, [1]).shape, dims) assert_equal(lag.lagval(x, [1, 0]).shape, dims) assert_equal(lag.lagval(x, [1, 0, 0]).shape, dims)
Example #5
Source File: test_polynomial.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_polyval(self): #check empty input assert_equal(poly.polyval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [x**i for i in range(5)] for i in range(5): tgt = y[i] res = poly.polyval(x, [0]*i + [1]) assert_almost_equal(res, tgt) tgt = x*(x**2 - 1) res = poly.polyval(x, [0, -1, 0, 1]) assert_almost_equal(res, tgt) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(poly.polyval(x, [1]).shape, dims) assert_equal(poly.polyval(x, [1, 0]).shape, dims) assert_equal(poly.polyval(x, [1, 0, 0]).shape, dims)
Example #6
Source File: test_polynomial.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_polyvander(self): # check for 1d x x = np.arange(3) v = poly.polyvander(x, 3) assert_(v.shape == (3, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], poly.polyval(x, coef)) # check for 2d x x = np.array([[1, 2], [3, 4], [5, 6]]) v = poly.polyvander(x, 3) assert_(v.shape == (3, 2, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], poly.polyval(x, coef))
Example #7
Source File: test_hermite.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_hermval(self): #check empty input assert_equal(herm.hermval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Hlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = herm.hermval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(herm.hermval(x, [1]).shape, dims) assert_equal(herm.hermval(x, [1, 0]).shape, dims) assert_equal(herm.hermval(x, [1, 0, 0]).shape, dims)
Example #8
Source File: computer.py From allesfitter with MIT License | 6 votes |
def baseline_hybrid_poly(*args): x, y, yerr_w, xx, params, inst, key = args polyorder = int(config.BASEMENT.settings['baseline_'+key+'_'+inst][-1]) xx = (xx - x[0])/x[-1] #polyfit needs the xx-axis scaled to [0,1], otherwise it goes nuts x = (x - x[0])/x[-1] #polyfit needs the x-axis scaled to [0,1], otherwise it goes nuts if polyorder>=0: yerr_weights = yerr_w/np.nanmean(yerr_w) weights = 1./yerr_weights ind = np.isfinite(y) #polyfit can't handle NaN params_poly = poly.polyfit(x[ind],y[ind],polyorder,w=weights[ind]) #WARNING: returns params in reverse order than np.polyfit!!! baseline = poly.polyval(xx, params_poly) #evaluate on xx (!) else: raise ValueError("'polyorder' has to be > 0.") return baseline #============================================================================== #::: calculate baseline: hybrid_spline (like Gillon+2012, but with a cubic spline) #==============================================================================
Example #9
Source File: test_hermite_e.py From coffeegrindsize with MIT License | 6 votes |
def test_hermeval(self): #check empty input assert_equal(herme.hermeval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Helist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = herme.hermeval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(herme.hermeval(x, [1]).shape, dims) assert_equal(herme.hermeval(x, [1, 0]).shape, dims) assert_equal(herme.hermeval(x, [1, 0, 0]).shape, dims)
Example #10
Source File: test_chebyshev.py From coffeegrindsize with MIT License | 6 votes |
def test_chebval(self): #check empty input assert_equal(cheb.chebval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Tlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = cheb.chebval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(cheb.chebval(x, [1]).shape, dims) assert_equal(cheb.chebval(x, [1, 0]).shape, dims) assert_equal(cheb.chebval(x, [1, 0, 0]).shape, dims)
Example #11
Source File: test_laguerre.py From coffeegrindsize with MIT License | 6 votes |
def test_lagval(self): #check empty input assert_equal(lag.lagval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Llist] for i in range(7): msg = "At i=%d" % i tgt = y[i] res = lag.lagval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(lag.lagval(x, [1]).shape, dims) assert_equal(lag.lagval(x, [1, 0]).shape, dims) assert_equal(lag.lagval(x, [1, 0, 0]).shape, dims)
Example #12
Source File: test_hermite_e.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_hermeval(self): #check empty input assert_equal(herme.hermeval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Helist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = herme.hermeval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(herme.hermeval(x, [1]).shape, dims) assert_equal(herme.hermeval(x, [1, 0]).shape, dims) assert_equal(herme.hermeval(x, [1, 0, 0]).shape, dims)
Example #13
Source File: test_polynomial.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def test_polyvander(self): # check for 1d x x = np.arange(3) v = poly.polyvander(x, 3) assert_(v.shape == (3, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], poly.polyval(x, coef)) # check for 2d x x = np.array([[1, 2], [3, 4], [5, 6]]) v = poly.polyvander(x, 3) assert_(v.shape == (3, 2, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], poly.polyval(x, coef))
Example #14
Source File: test_polynomial.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def test_polyval(self): #check empty input assert_equal(poly.polyval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [x**i for i in range(5)] for i in range(5): tgt = y[i] res = poly.polyval(x, [0]*i + [1]) assert_almost_equal(res, tgt) tgt = x*(x**2 - 1) res = poly.polyval(x, [0, -1, 0, 1]) assert_almost_equal(res, tgt) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(poly.polyval(x, [1]).shape, dims) assert_equal(poly.polyval(x, [1, 0]).shape, dims) assert_equal(poly.polyval(x, [1, 0, 0]).shape, dims)
Example #15
Source File: test_laguerre.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def test_lagval(self): #check empty input assert_equal(lag.lagval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Llist] for i in range(7): msg = "At i=%d" % i tgt = y[i] res = lag.lagval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(lag.lagval(x, [1]).shape, dims) assert_equal(lag.lagval(x, [1, 0]).shape, dims) assert_equal(lag.lagval(x, [1, 0, 0]).shape, dims)
Example #16
Source File: test_hermite.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def test_hermval(self): #check empty input assert_equal(herm.hermval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Hlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = herm.hermval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(herm.hermval(x, [1]).shape, dims) assert_equal(herm.hermval(x, [1, 0]).shape, dims) assert_equal(herm.hermval(x, [1, 0, 0]).shape, dims)
Example #17
Source File: test_hermite_e.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def test_hermeval(self): #check empty input assert_equal(herme.hermeval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Helist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = herme.hermeval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(herme.hermeval(x, [1]).shape, dims) assert_equal(herme.hermeval(x, [1, 0]).shape, dims) assert_equal(herme.hermeval(x, [1, 0, 0]).shape, dims)
Example #18
Source File: test_hermite.py From pySINDy with MIT License | 6 votes |
def test_hermval(self): #check empty input assert_equal(herm.hermval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Hlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = herm.hermval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(herm.hermval(x, [1]).shape, dims) assert_equal(herm.hermval(x, [1, 0]).shape, dims) assert_equal(herm.hermval(x, [1, 0, 0]).shape, dims)
Example #19
Source File: test_polynomial.py From pySINDy with MIT License | 6 votes |
def test_polyvander(self): # check for 1d x x = np.arange(3) v = poly.polyvander(x, 3) assert_(v.shape == (3, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], poly.polyval(x, coef)) # check for 2d x x = np.array([[1, 2], [3, 4], [5, 6]]) v = poly.polyvander(x, 3) assert_(v.shape == (3, 2, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], poly.polyval(x, coef))
Example #20
Source File: test_polynomial.py From pySINDy with MIT License | 6 votes |
def test_polyval(self): #check empty input assert_equal(poly.polyval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [x**i for i in range(5)] for i in range(5): tgt = y[i] res = poly.polyval(x, [0]*i + [1]) assert_almost_equal(res, tgt) tgt = x*(x**2 - 1) res = poly.polyval(x, [0, -1, 0, 1]) assert_almost_equal(res, tgt) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(poly.polyval(x, [1]).shape, dims) assert_equal(poly.polyval(x, [1, 0]).shape, dims) assert_equal(poly.polyval(x, [1, 0, 0]).shape, dims)
Example #21
Source File: test_laguerre.py From pySINDy with MIT License | 6 votes |
def test_lagval(self): #check empty input assert_equal(lag.lagval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Llist] for i in range(7): msg = "At i=%d" % i tgt = y[i] res = lag.lagval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(lag.lagval(x, [1]).shape, dims) assert_equal(lag.lagval(x, [1, 0]).shape, dims) assert_equal(lag.lagval(x, [1, 0, 0]).shape, dims)
Example #22
Source File: test_chebyshev.py From pySINDy with MIT License | 6 votes |
def test_chebval(self): #check empty input assert_equal(cheb.chebval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Tlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = cheb.chebval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(cheb.chebval(x, [1]).shape, dims) assert_equal(cheb.chebval(x, [1, 0]).shape, dims) assert_equal(cheb.chebval(x, [1, 0, 0]).shape, dims)
Example #23
Source File: test_hermite_e.py From pySINDy with MIT License | 6 votes |
def test_hermeval(self): #check empty input assert_equal(herme.hermeval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Helist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = herme.hermeval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(herme.hermeval(x, [1]).shape, dims) assert_equal(herme.hermeval(x, [1, 0]).shape, dims) assert_equal(herme.hermeval(x, [1, 0, 0]).shape, dims)
Example #24
Source File: test_hermite.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_hermval(self): #check empty input assert_equal(herm.hermval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Hlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = herm.hermval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(herm.hermval(x, [1]).shape, dims) assert_equal(herm.hermval(x, [1, 0]).shape, dims) assert_equal(herm.hermval(x, [1, 0, 0]).shape, dims)
Example #25
Source File: test_polynomial.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_polyvander(self): # check for 1d x x = np.arange(3) v = poly.polyvander(x, 3) assert_(v.shape == (3, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], poly.polyval(x, coef)) # check for 2d x x = np.array([[1, 2], [3, 4], [5, 6]]) v = poly.polyvander(x, 3) assert_(v.shape == (3, 2, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], poly.polyval(x, coef))
Example #26
Source File: test_polynomial.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_polyval(self): #check empty input assert_equal(poly.polyval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [x**i for i in range(5)] for i in range(5): tgt = y[i] res = poly.polyval(x, [0]*i + [1]) assert_almost_equal(res, tgt) tgt = x*(x**2 - 1) res = poly.polyval(x, [0, -1, 0, 1]) assert_almost_equal(res, tgt) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(poly.polyval(x, [1]).shape, dims) assert_equal(poly.polyval(x, [1, 0]).shape, dims) assert_equal(poly.polyval(x, [1, 0, 0]).shape, dims)
Example #27
Source File: test_laguerre.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_lagval(self): #check empty input assert_equal(lag.lagval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Llist] for i in range(7): msg = "At i=%d" % i tgt = y[i] res = lag.lagval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(lag.lagval(x, [1]).shape, dims) assert_equal(lag.lagval(x, [1, 0]).shape, dims) assert_equal(lag.lagval(x, [1, 0, 0]).shape, dims)
Example #28
Source File: test_chebyshev.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_chebval(self): #check empty input assert_equal(cheb.chebval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Tlist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = cheb.chebval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(cheb.chebval(x, [1]).shape, dims) assert_equal(cheb.chebval(x, [1, 0]).shape, dims) assert_equal(cheb.chebval(x, [1, 0, 0]).shape, dims)
Example #29
Source File: test_hermite_e.py From recruit with Apache License 2.0 | 6 votes |
def test_hermeval(self): #check empty input assert_equal(herme.hermeval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Helist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = herme.hermeval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(herme.hermeval(x, [1]).shape, dims) assert_equal(herme.hermeval(x, [1, 0]).shape, dims) assert_equal(herme.hermeval(x, [1, 0, 0]).shape, dims)
Example #30
Source File: filter_design.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _campos_zeros(n): """ Return approximate zero locations of Bessel polynomials y_n(x) for order `n` using polynomial fit (Campos-Calderon 2011) """ if n == 1: return asarray([-1+0j]) s = npp_polyval(n, [0, 0, 2, 0, -3, 1]) b3 = npp_polyval(n, [16, -8]) / s b2 = npp_polyval(n, [-24, -12, 12]) / s b1 = npp_polyval(n, [8, 24, -12, -2]) / s b0 = npp_polyval(n, [0, -6, 0, 5, -1]) / s r = npp_polyval(n, [0, 0, 2, 1]) a1 = npp_polyval(n, [-6, -6]) / r a2 = 6 / r k = np.arange(1, n+1) x = npp_polyval(k, [0, a1, a2]) y = npp_polyval(k, [b0, b1, b2, b3]) return x + 1j*y