code: def test_complex(self):
      def tfunc(x):
          return np.exp(1j * x)
  
      assert np.allclose(
          quad(tfunc, 0, np.pi / 2, complex_func=True)[0], 1 + 1j
      )
  
      # We consider a divergent case in order to force quadpack
      # to return an error message.  The output is compared
      # against what is returned by explicit integration
      # of the parts.
      kwargs = {
          "a": 0,
          "b": np.inf,
          "full_output": True,
          "weight": "cos",
          "wvar": 1,
      }
      res_c = quad(tfunc, complex_func=True, **kwargs)
      res_r = quad(
          lambda x: np.real(np.exp(1j * x)),
          complex_func=False,
          **kwargs,
      )
      res_i = quad(
          lambda x: np.imag(np.exp(1j * x)),
          complex_func=False,
          **kwargs,
      )
  
      np.testing.assert_equal(res_c[0], res_r[0] + 1j * res_i[0])
      np.testing.assert_equal(res_c[1], res_r[1] + 1j * res_i[1])
  
      assert len(res_c[2]["real"]) == len(res_r[2:]) == 3
      assert res_c[2]["real"][2] == res_r[4]
      assert res_c[2]["real"][1] == res_r[3]
      assert res_c[2]["real"][0]["lst"] == res_r[2]["lst"]
  
      assert len(res_c[2]["imag"]) == len(res_i[2:]) == 1
      assert res_c[2]["imag"][0]["lst"] == res_i[2]["lst"]
  
imports: import sys
  import math
  import numpy
  from numpy import sqrt, cos, sin, arctan, exp, log, pi
  from numpy.testing import assert_, assert_allclose, assert_array_less, assert_almost_equal
  import pytest
  from scipy.integrate import quad, dblquad, tplquad, nquad
  from scipy.special import erf, erfc
  from scipy._lib._ccallback import LowLevelCallable
  import ctypes
  import ctypes.util
  from scipy._lib._ccallback_c import sine_ctypes
  import scipy.integrate._test_multivariate
label_desc: Use image node_id 19 for calling the TestQuad obj's underlying member method code with example usage: obj.test_complex() and returns: np