Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
svgpathtools / test / test_polytools.py
Size: Mime:
# External dependencies
from __future__ import division, absolute_import, print_function
import unittest
import numpy as np

# Internal dependencies
from svgpathtools import rational_limit


class Test_polytools(unittest.TestCase):
    # def test_poly_roots(self):
    #     self.fail()

    def test_rational_limit(self):

        # (3x^3 + x)/(4x^2 - 2x) -> -1/2 as x->0
        f = np.poly1d([3, 0, 1, 0])
        g = np.poly1d([4, -2, 0])
        lim = rational_limit(f, g, 0)
        self.assertAlmostEqual(lim, -0.5)

        # (3x^2)/(4x^2 - 2x) -> 0 as x->0
        f = np.poly1d([3, 0, 0])
        g = np.poly1d([4, -2, 0])
        lim = rational_limit(f, g, 0)
        self.assertAlmostEqual(lim, 0)


if __name__ == '__main__':
    unittest.main()