code: def test_complex_halley():
      """Test Halley's works with complex roots"""
  
      def f(x, *a):
          return a[0] * x**2 + a[1] * x + a[2]
  
      def f_1(x, *a):
          return 2 * a[0] * x + a[1]
  
      def f_2(x, *a):
          retval = 2 * a[0]
          try:
              size = len(x)
          except TypeError:
              return retval
          else:
              return [retval] * size
  
      z = complex(1.0, 2.0)
      coeffs = (2.0, 3.0, 4.0)
      y = zeros.newton(
          f, z, args=coeffs, fprime=f_1, fprime2=f_2, tol=1e-6
      )
      # (-0.75000000000000078+1.1989578808281789j)
      assert_allclose(f(y, *coeffs), 0, atol=1e-6)
      z = [z] * 10
      coeffs = (2.0, 3.0, 4.0)
      y = zeros.newton(
          f, z, args=coeffs, fprime=f_1, fprime2=f_2, tol=1e-6
      )
      assert_allclose(f(y, *coeffs), 0, atol=1e-6)
  
imports: from __future__ import division, print_function, absolute_import
  import pytest
  from math import sqrt, exp, sin, cos
  from numpy.testing import assert_warns, assert_, assert_allclose, assert_equal, assert_array_equal
  import numpy
  from numpy import finfo, power, nan, isclose
  from scipy.optimize import zeros, newton, root_scalar
  from scipy._lib._util import getargspec_no_self
  from scipy.optimize._tstutils import get_tests, functions, fstrings
  from scipy._lib._numpy_compat import suppress_warnings
label_desc: Use image node_id 10 for calling a global function with example usage: test_complex_halley() and returns: unknown, unknown, unknown, retval