def np_complex_atan_impl(context, builder, sig, args):
    # npymath does not provide a complex atan. The code in funcs.inc.src
    # is translated here...
    _check_arity_and_homogeneity(sig, args, 1)

    ty = sig.args[0]
    float_ty = ty.underlying_float
    epsilon = context.get_constant(float_ty, 1e-3)

    # if real or imag has magnitude over 1e-3...
    x = context.make_complex(builder, ty, value=args[0])
    out = context.make_complex(builder, ty)
    abs_r = _fabs(context, builder, x.real)
    abs_i = _fabs(context, builder, x.imag)
    abs_r_gt_epsilon = builder.fcmp(lc.FCMP_OGT, abs_r, epsilon)
    abs_i_gt_epsilon = builder.fcmp(lc.FCMP_OGT, abs_i, epsilon)
    any_gt_epsilon = builder.or_(abs_r_gt_epsilon, abs_i_gt_epsilon)
    binary_sig = typing.signature(*[ty]*3)
    with builder.if_else(any_gt_epsilon) as (then, otherwise):
        with then:
            # ... then use formula
            # 0.5j * log((j + x)/(j - x))
            I = context.get_constant_generic(builder, ty, 0.0 + 1.0j)
            I2 = context.get_constant_generic(builder, ty, 0.0 + 0.5j)
            den = numbers.complex_sub_impl(context, builder, binary_sig,
                                            [I, args[0]])
            num = numbers.complex_add_impl(context, builder, binary_sig,
                                            [I, args[0]])
            div = np_complex_div_impl(context, builder, binary_sig,
                                      [num, den])
            log = np_complex_log_impl(context, builder, sig, [div])
            res = numbers.complex_mul_impl(context, builder, binary_sig,
                                            [I2, log])

            out._setvalue(res)
        with otherwise:
            # else use series expansion (to avoid loss of precision)
            coef_dict = {
                types.complex64: [-1.0/3.0, 5.0/-3.0],
                types.complex128: [-1.0/3.0, -3.0/5.0, -5.0/7.0],
                # types.complex256: [-1.0/3.0, -3.0/5.0, -5.0/7.0, -7.0/9.0, -9.0/11.0]
            }

            xx = np_complex_square_impl(context, builder, sig, args)
            ONE = context.get_constant_generic(builder, ty, 1.0 + 0.0j)
            tmp = _complex_expand_series(context, builder, ty,
                                         ONE, xx, coef_dict[ty])
            out._setvalue(numbers.complex_mul_impl(context, builder,
                                                    binary_sig,
                                                    [args[0], tmp]))

    return out._getvalue()


########################################################################
# NumPy atan2
dataset/ETHPy150Open numba/numba/numba/targets/npyfuncs.py/np_complex_atan_impl/swapped operands of `/`