def _mathfun(f_real, f_complex):
    def f(x, **kwargs):
        if type(x) is complex:
            return f_complex(x)
        try:
            return f_real(float(x))
        except (TypeError, __HOLE__):
            return f_complex(complex(x))
    f.__name__ = f_real.__name__
    return f
dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/math2.py/_mathfun