Python numpy.polydiv() Examples
The following are 30 code examples for showing how to use numpy.polydiv(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example 1
Project: recruit Author: Frank-qlu File: test_polynomial.py License: 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
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_polynomial.py License: 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 3
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_polynomial.py License: 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 4
Project: coffeegrindsize Author: jgagneastro File: test_polynomial.py License: 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
Project: recruit Author: Frank-qlu File: test_polynomial.py License: 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 6
Project: recruit Author: Frank-qlu File: test_regression.py License: 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 7
Project: recruit Author: Frank-qlu File: test_regression.py License: 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 8
Project: lambda-packs Author: ryfeus File: test_regression.py License: 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 9
Project: lambda-packs Author: ryfeus File: test_regression.py License: 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 10
Project: auto-alt-text-lambda-api Author: abhisuri97 File: test_regression.py License: 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
Project: auto-alt-text-lambda-api Author: abhisuri97 File: test_regression.py License: 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
Project: vnpy_crypto Author: birforce File: test_regression.py License: 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 13
Project: vnpy_crypto Author: birforce File: test_regression.py License: 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 14
Project: Computable Author: ktraunmueller File: test_regression.py License: 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 15
Project: Computable Author: ktraunmueller File: test_regression.py License: 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 16
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_polynomial.py License: 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 17
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_regression.py License: 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 18
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_regression.py License: 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 19
Project: GraphicDesignPatternByPython Author: Relph1119 File: test_polynomial.py License: 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 20
Project: GraphicDesignPatternByPython Author: Relph1119 File: test_regression.py License: 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 21
Project: GraphicDesignPatternByPython Author: Relph1119 File: test_regression.py License: 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 22
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_polynomial.py License: 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 23
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_regression.py License: 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 24
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_regression.py License: 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 25
Project: pySINDy Author: luckystarufo File: test_polynomial.py License: 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 26
Project: pySINDy Author: luckystarufo File: test_regression.py License: 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 27
Project: pySINDy Author: luckystarufo File: test_regression.py License: 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 28
Project: mxnet-lambda Author: awslabs File: test_regression.py License: 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 29
Project: mxnet-lambda Author: awslabs File: test_regression.py License: 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 30
Project: ImageFusion Author: pfchai File: test_regression.py License: 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)