Skip to content

Hang in sine integral function with NaN input #481

Description

@jacksonvanover

mpmath version: 1.1.0

When using the fp context, if the argument to the sine integral function is a NaN, a hang is
caused. The mp context returns a NaN.

Example:

Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from mpmath import *
>>> import numpy as np
>>> mp.si(np.nan)
mpf('nan')
>>> fp.si(np.nan)
^CTraceback (most recent call last):
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/functions/expintegrals.py", line 359, in si
    return ctx._si(z)
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/functions/functions.py", line 78, in _si
    def _si(ctx, z): raise NotImplementedError
NotImplementedError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/functions/expintegrals.py", line 361, in si
    return ctx._si_generic(z)
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/ctx_fp.py", line 57, in f_wrapped
    return f(ctx, *args, **kwargs)
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/functions/expintegrals.py", line 372, in _si_generic
    v = (-0.5j)*(ctx.ei(jz) - ctx.ei(njz))
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/functions/expintegrals.py", line 290, in ei
    return ctx._ei(z)
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/math2.py", line 574, in ei
    ref = ei_asymp(zref, _e1)
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/math2.py", line 508, in ei_asymp
    t *= k*r
KeyboardInterrupt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions