Python numpy.polydiv() Examples
The following are 30
code examples of numpy.polydiv().
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
, or try the search function
.
Example #1
Source File: test_polynomial.py From recruit with Apache License 2.0 | 6 votes |
def test_poly1d_math(self): # here we use some simple coeffs to make calculations easier p = np.poly1d([1., 2, 4]) q = np.poly1d([4., 2, 1]) assert_equal(p/q, (np.poly1d([0.25]), np.poly1d([1.5, 3.75]))) assert_equal(p.integ(), np.poly1d([1/3, 1., 4., 0.])) assert_equal(p.integ(1), np.poly1d([1/3, 1., 4., 0.])) p = np.poly1d([1., 2, 3]) q = np.poly1d([3., 2, 1]) assert_equal(p * q, np.poly1d([3., 8., 14., 8., 3.])) assert_equal(p + q, np.poly1d([4., 4., 4.])) assert_equal(p - q, np.poly1d([-2., 0., 2.])) assert_equal(p ** 4, np.poly1d([1., 8., 36., 104., 214., 312., 324., 216., 81.])) assert_equal(p(q), np.poly1d([9., 12., 16., 8., 6.])) assert_equal(q(p), np.poly1d([3., 12., 32., 40., 34.])) assert_equal(p.deriv(), np.poly1d([2., 2.])) assert_equal(p.deriv(2), np.poly1d([2.])) assert_equal(np.polydiv(np.poly1d([1, 0, -1]), np.poly1d([1, 1])), (np.poly1d([1., -1.]), np.poly1d([0.])))
Example #2
Source File: test_polynomial.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_poly1d_math(self): # here we use some simple coeffs to make calculations easier p = np.poly1d([1., 2, 4]) q = np.poly1d([4., 2, 1]) assert_equal(p/q, (np.poly1d([0.25]), np.poly1d([1.5, 3.75]))) assert_equal(p.integ(), np.poly1d([1/3, 1., 4., 0.])) assert_equal(p.integ(1), np.poly1d([1/3, 1., 4., 0.])) p = np.poly1d([1., 2, 3]) q = np.poly1d([3., 2, 1]) assert_equal(p * q, np.poly1d([3., 8., 14., 8., 3.])) assert_equal(p + q, np.poly1d([4., 4., 4.])) assert_equal(p - q, np.poly1d([-2., 0., 2.])) assert_equal(p ** 4, np.poly1d([1., 8., 36., 104., 214., 312., 324., 216., 81.])) assert_equal(p(q), np.poly1d([9., 12., 16., 8., 6.])) assert_equal(q(p), np.poly1d([3., 12., 32., 40., 34.])) assert_equal(p.deriv(), np.poly1d([2., 2.])) assert_equal(p.deriv(2), np.poly1d([2.])) assert_equal(np.polydiv(np.poly1d([1, 0, -1]), np.poly1d([1, 1])), (np.poly1d([1., -1.]), np.poly1d([0.])))
Example #3
Source File: test_polynomial.py From coffeegrindsize with MIT License | 6 votes |
def test_poly1d_math(self): # here we use some simple coeffs to make calculations easier p = np.poly1d([1., 2, 4]) q = np.poly1d([4., 2, 1]) assert_equal(p/q, (np.poly1d([0.25]), np.poly1d([1.5, 3.75]))) assert_equal(p.integ(), np.poly1d([1/3, 1., 4., 0.])) assert_equal(p.integ(1), np.poly1d([1/3, 1., 4., 0.])) p = np.poly1d([1., 2, 3]) q = np.poly1d([3., 2, 1]) assert_equal(p * q, np.poly1d([3., 8., 14., 8., 3.])) assert_equal(p + q, np.poly1d([4., 4., 4.])) assert_equal(p - q, np.poly1d([-2., 0., 2.])) assert_equal(p ** 4, np.poly1d([1., 8., 36., 104., 214., 312., 324., 216., 81.])) assert_equal(p(q), np.poly1d([9., 12., 16., 8., 6.])) assert_equal(q(p), np.poly1d([3., 12., 32., 40., 34.])) assert_equal(p.deriv(), np.poly1d([2., 2.])) assert_equal(p.deriv(2), np.poly1d([2.])) assert_equal(np.polydiv(np.poly1d([1, 0, -1]), np.poly1d([1, 1])), (np.poly1d([1., -1.]), np.poly1d([0.])))
Example #4
Source File: test_polynomial.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def test_poly1d_math(self): # here we use some simple coeffs to make calculations easier p = np.poly1d([1., 2, 4]) q = np.poly1d([4., 2, 1]) assert_equal(p/q, (np.poly1d([0.25]), np.poly1d([1.5, 3.75]))) assert_equal(p.integ(), np.poly1d([1/3, 1., 4., 0.])) assert_equal(p.integ(1), np.poly1d([1/3, 1., 4., 0.])) p = np.poly1d([1., 2, 3]) q = np.poly1d([3., 2, 1]) assert_equal(p * q, np.poly1d([3., 8., 14., 8., 3.])) assert_equal(p + q, np.poly1d([4., 4., 4.])) assert_equal(p - q, np.poly1d([-2., 0., 2.])) assert_equal(p ** 4, np.poly1d([1., 8., 36., 104., 214., 312., 324., 216., 81.])) assert_equal(p(q), np.poly1d([9., 12., 16., 8., 6.])) assert_equal(q(p), np.poly1d([3., 12., 32., 40., 34.])) assert_equal(p.deriv(), np.poly1d([2., 2.])) assert_equal(p.deriv(2), np.poly1d([2.])) assert_equal(np.polydiv(np.poly1d([1, 0, -1]), np.poly1d([1, 1])), (np.poly1d([1., -1.]), np.poly1d([0.])))
Example #5
Source File: test_regression.py From pySINDy with MIT License | 5 votes |
def test_poly_div(self): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #6
Source File: test_regression.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=complex) q, r = np.polydiv(x, x) assert_(q.dtype == complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=int) q, r = np.polydiv(x, x) assert_(q.dtype == float, msg)
Example #7
Source File: test_regression.py From pySINDy with MIT License | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=complex) q, r = np.polydiv(x, x) assert_(q.dtype == complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=int) q, r = np.polydiv(x, x) assert_(q.dtype == float, msg)
Example #8
Source File: test_regression.py From mxnet-lambda with Apache License 2.0 | 5 votes |
def test_poly_div(self, level=rlevel): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #9
Source File: test_regression.py From mxnet-lambda with Apache License 2.0 | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=np.complex) q, r = np.polydiv(x, x) assert_(q.dtype == np.complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=np.int) q, r = np.polydiv(x, x) assert_(q.dtype == np.float, msg)
Example #10
Source File: test_regression.py From ImageFusion with MIT License | 5 votes |
def test_poly_div(self, level=rlevel): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #11
Source File: test_regression.py From ImageFusion with MIT License | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=np.complex) q, r = np.polydiv(x, x) assert_(q.dtype == np.complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=np.int) q, r = np.polydiv(x, x) assert_(q.dtype == np.float, msg)
Example #12
Source File: test_regression.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_poly_div(self, level=rlevel): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #13
Source File: test_regression.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=np.complex) q, r = np.polydiv(x, x) assert_(q.dtype == np.complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=np.int) q, r = np.polydiv(x, x) assert_(q.dtype == np.float, msg)
Example #14
Source File: test_polynomial.py From coffeegrindsize with MIT License | 5 votes |
def test_polydiv(self): b = np.poly1d([2, 6, 6, 1]) a = np.poly1d([-1j, (1+2j), -(2+1j), 1]) q, r = np.polydiv(b, a) assert_equal(q.coeffs.dtype, np.complex128) assert_equal(r.coeffs.dtype, np.complex128) assert_equal(q*a + r, b)
Example #15
Source File: test_regression.py From coffeegrindsize with MIT License | 5 votes |
def test_poly_div(self): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #16
Source File: test_regression.py From coffeegrindsize with MIT License | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=complex) q, r = np.polydiv(x, x) assert_(q.dtype == complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=int) q, r = np.polydiv(x, x) assert_(q.dtype == float, msg)
Example #17
Source File: test_polynomial.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def test_polydiv(self): b = np.poly1d([2, 6, 6, 1]) a = np.poly1d([-1j, (1+2j), -(2+1j), 1]) q, r = np.polydiv(b, a) assert_equal(q.coeffs.dtype, np.complex128) assert_equal(r.coeffs.dtype, np.complex128) assert_equal(q*a + r, b)
Example #18
Source File: test_regression.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def test_poly_div(self): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #19
Source File: test_regression.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=complex) q, r = np.polydiv(x, x) assert_(q.dtype == complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=int) q, r = np.polydiv(x, x) assert_(q.dtype == float, msg)
Example #20
Source File: test_polynomial.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_polydiv(self): b = np.poly1d([2, 6, 6, 1]) a = np.poly1d([-1j, (1+2j), -(2+1j), 1]) q, r = np.polydiv(b, a) assert_equal(q.coeffs.dtype, np.complex128) assert_equal(r.coeffs.dtype, np.complex128) assert_equal(q*a + r, b)
Example #21
Source File: test_regression.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_poly_div(self): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #22
Source File: test_regression.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=complex) q, r = np.polydiv(x, x) assert_(q.dtype == complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=int) q, r = np.polydiv(x, x) assert_(q.dtype == float, msg)
Example #23
Source File: test_regression.py From keras-lambda with MIT License | 5 votes |
def test_poly_div(self, level=rlevel): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #24
Source File: test_regression.py From keras-lambda with MIT License | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=np.complex) q, r = np.polydiv(x, x) assert_(q.dtype == np.complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=np.int) q, r = np.polydiv(x, x) assert_(q.dtype == np.float, msg)
Example #25
Source File: test_regression.py From Computable with MIT License | 5 votes |
def test_poly_div(self, level=rlevel): """Ticket #553""" u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #26
Source File: test_polynomial.py From recruit with Apache License 2.0 | 5 votes |
def test_polydiv(self): b = np.poly1d([2, 6, 6, 1]) a = np.poly1d([-1j, (1+2j), -(2+1j), 1]) q, r = np.polydiv(b, a) assert_equal(q.coeffs.dtype, np.complex128) assert_equal(r.coeffs.dtype, np.complex128) assert_equal(q*a + r, b)
Example #27
Source File: test_regression.py From recruit with Apache License 2.0 | 5 votes |
def test_poly_div(self): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #28
Source File: test_regression.py From recruit with Apache License 2.0 | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=complex) q, r = np.polydiv(x, x) assert_(q.dtype == complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=int) q, r = np.polydiv(x, x) assert_(q.dtype == float, msg)
Example #29
Source File: test_regression.py From lambda-packs with MIT License | 5 votes |
def test_poly_div(self, level=rlevel): # Ticket #553 u = np.poly1d([1, 2, 3]) v = np.poly1d([1, 2, 3, 4, 5]) q, r = np.polydiv(u, v) assert_equal(q*v + r, u)
Example #30
Source File: test_regression.py From lambda-packs with MIT License | 5 votes |
def test_polydiv_type(self): # Make polydiv work for complex types msg = "Wrong type, should be complex" x = np.ones(3, dtype=np.complex) q, r = np.polydiv(x, x) assert_(q.dtype == np.complex, msg) msg = "Wrong type, should be float" x = np.ones(3, dtype=np.int) q, r = np.polydiv(x, x) assert_(q.dtype == np.float, msg)