Skip to content

Hang in cosine integral function with NaN input #480

Description

@jacksonvanover

mpmath version: 1.1.0

When the argument to the floating-point precision version of the cosine integral function is a NaN, a hang is
caused. The mp version returns 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.ci(np.nan)
mpf('nan')
>>> fp.ci(np.nan)
^CTraceback (most recent call last):
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/functions/expintegrals.py", line 332, in ci
    return ctx._ci(z)
  File "/home/jvanover/.local/lib/python3.6/site-packages/mpmath/functions/functions.py", line 77, in _ci
    def _ci(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 334, in ci
    return ctx._ci_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 343, in _ci_generic
    v = 0.5*(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 509, in ei_asymp
    s += t
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