Ticket #11334: trac_11334-divide.patch

File trac_11334-divide.patch, 7.9 KB (added by fbissey, 7 years ago)

add divide by 0 warnings

  • sage/calculus/interpolators.pyx

    # HG changeset patch
    # User Francois Bissey <francois.bissey@canterbury.ac.nz>
    # Date 1363859472 -46800
    # Node ID 04672e3f53435618ce58a87ac95d677962edec26
    # Parent  d5f2dfc014530707f8a3744f4867c0073e08c0b9
    trac 11334: fix all numpy's divide warning
    
    diff --git a/sage/calculus/interpolators.pyx b/sage/calculus/interpolators.pyx
    a b  
    5050        sage: fy = lambda x: ps.value(x).imag
    5151        sage: show(parametric_plot((fx, fy), (0, 2*pi)))
    5252        sage: m = Riemann_Map([lambda x: ps.value(real(x))], [lambda x: ps.derivative(real(x))],0)
     53        doctest:1: RuntimeWarning: divide by zero encountered in divide
    5354        sage: show(m.plot_colored() + m.plot_spiderweb())
    5455
    5556    Polygon approximation of an circle::
     
    181182        sage: fy = lambda x: cs.value(x).imag
    182183        sage: show(parametric_plot((fx, fy), (0, 2*pi)))
    183184        sage: m = Riemann_Map([lambda x: cs.value(real(x))], [lambda x: cs.derivative(real(x))], 0)
     185        doctest:1: RuntimeWarning: divide by zero encountered in divide
    184186        sage: show(m.plot_colored() + m.plot_spiderweb())
    185187
    186188    Polygon approximation of a circle::
  • sage/calculus/riemann.pyx

    diff --git a/sage/calculus/riemann.pyx b/sage/calculus/riemann.pyx
    a b  
    109109        sage: f(t) = e^(I*t)
    110110        sage: fprime(t) = I*e^(I*t)
    111111        sage: m = Riemann_Map([f], [fprime], 0)  # long time (4 sec)
     112        doctest:1: RuntimeWarning: divide by zero encountered in divide
    112113
    113114    The unit circle with a small hole::
    114115
     
    161162            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    162163            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    163164            sage: m = Riemann_Map([f], [fprime], 0)
     165            doctest:1: RuntimeWarning: divide by zero encountered in divide
    164166        """
    165167        a = np.complex128(a)
    166168        if N <= 2:
     
    212214            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    213215            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    214216            sage: isinstance(Riemann_Map([f], [fprime], 0)._repr_(), str)  # long time
     217            doctest:1: RuntimeWarning: divide by zero encountered in divide
    215218            True
    216219        """
    217220        return "A Riemann mapping of a figure to the unit circle."
     
    226229            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    227230            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    228231            sage: m = Riemann_Map([f], [fprime], 0)
     232            doctest:1: RuntimeWarning: divide by zero encountered in divide
    229233        """
    230234        cp = self.cps.flatten()
    231235        dp = self.dps.flatten()
     
    332336            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    333337            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    334338            sage: m = Riemann_Map([f], [fprime], 0)
     339            doctest:1: RuntimeWarning: divide by zero encountered in divide
    335340            sage: sz = m.get_szego(boundary=0)
    336341            sage: points = m.get_szego(absolute_value=True)
    337342            sage: list_plot(points)
     
    402407            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    403408            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    404409            sage: m = Riemann_Map([f], [fprime], 0)
     410            doctest:1: RuntimeWarning: divide by zero encountered in divide
    405411            sage: points = m.get_theta_points()
    406412            sage: list_plot(points)
    407413
     
    445451            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    446452            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    447453            sage: m = Riemann_Map([f], [fprime], 0)
     454            doctest:1: RuntimeWarning: divide by zero encountered in divide
    448455        """
    449456        cdef int N = self.N
    450457        cdef double complex coeff = 3*I / (8*N)
     
    513520            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    514521            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    515522            sage: m = Riemann_Map([f], [fprime], 0)
     523            doctest:1: RuntimeWarning: divide by zero encountered in divide
    516524            sage: m.riemann_map(0.25 + sqrt(-0.5))
    517525            (0.137514...+0.87669602...j)
    518526            sage: m.riemann_map(1.3*I)
     
    541549            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    542550            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    543551            sage: m = Riemann_Map([f], [fprime], 0)
     552            doctest:1: RuntimeWarning: divide by zero encountered in divide
    544553        """
    545554        cdef int N = self.N
    546555        cdef int B = self.B
     
    593602            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    594603            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    595604            sage: m = Riemann_Map([f], [fprime], 0)
     605            doctest:1: RuntimeWarning: divide by zero encountered in divide
    596606            sage: m.inverse_riemann_map(0.5 + sqrt(-0.5))
    597607            (0.406880548363...+0.361470279816...j)
    598608            sage: m.inverse_riemann_map(0.95)
     
    645655            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    646656            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    647657            sage: m = Riemann_Map([f], [fprime], 0)
     658            doctest:1: RuntimeWarning: divide by zero encountered in divide
    648659
    649660        Default plot::
    650661
     
    710721            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    711722            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    712723            sage: m = Riemann_Map([f], [fprime], 0)
     724            doctest:1: RuntimeWarning: divide by zero encountered in divide
    713725
    714726        Default plot::
    715727
     
    799811            sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    800812            sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    801813            sage: m = Riemann_Map([f], [fprime], 0)
     814            doctest:1: RuntimeWarning: divide by zero encountered in divide
    802815            sage: m.plot_colored()
    803816
    804817        Plot zoomed in on a specific spot::
     
    865878        sage: f(t) = e^(I*t) - 0.5*e^(-I*t)
    866879        sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t)
    867880        sage: m = Riemann_Map([f], [fprime], 0)
     881        doctest:1: RuntimeWarning: divide by zero encountered in divide
    868882        sage: m.plot_spiderweb()
    869883    """
    870884    list2 = range(len(clist) + 1) if loop else range(len(clist))
  • sage/functions/hyperbolic.py

    diff --git a/sage/functions/hyperbolic.py b/sage/functions/hyperbolic.py
    a b  
    608608            sage: import numpy
    609609            sage: a = numpy.linspace(0,1,3)
    610610            sage: arcsech(a)
    611             Warning: divide by zero encountered in divide
     611            doctest:614: RuntimeWarning: divide by zero encountered in divide
    612612            array([       inf,  1.3169579,  0.       ])
    613613        """
    614614        return arccosh(1.0 / x)
     
    658658            sage: import numpy
    659659            sage: a = numpy.linspace(0,1,3)
    660660            sage: arccsch(a)
    661             Warning: divide by zero encountered in divide
     661            doctest:664: RuntimeWarning: divide by zero encountered in divide
    662662            array([        inf,  1.44363548,  0.88137359])
    663663        """
    664664        return arcsinh(1.0 / x)
  • sage/modules/vector_double_dense.pyx

    diff --git a/sage/modules/vector_double_dense.pyx b/sage/modules/vector_double_dense.pyx
    a b  
    710710            0.953760808...
    711711            sage: w = vector(CDF, [-1,0,1])
    712712            sage: w.norm(p=-1.6)
    713             Warning: divide by zero encountered in power
     713            doctest:1992: RuntimeWarning: divide by zero encountered in power
    714714            0.0
    715715
    716716        Return values are in ``RDF``, or an integer when ``p = 0``.  ::
  • sage/symbolic/function.pyx

    diff --git a/sage/symbolic/function.pyx b/sage/symbolic/function.pyx
    a b  
    622622            sage: import numpy
    623623            sage: a = numpy.arange(5)
    624624            sage: csc(a)
    625             Warning: divide by zero encountered in divide
     625            doctest:270: RuntimeWarning: divide by zero encountered in divide
    626626            array([        inf,  1.18839511,  1.09975017,  7.0861674 , -1.32134871])
    627627
    628628            sage: factorial(a)