code: def test_wigner_d():
      half = S(1) / 2
      assert wigner_d_small(half, 0) == Matrix([[1, 0], [0, 1]])
      assert wigner_d_small(half, pi / 2) == Matrix(
          [[1, 1], [-1, 1]]
      ) / sqrt(2)
      assert wigner_d_small(half, pi) == Matrix([[0, 1], [-1, 0]])
  
      alpha, beta, gamma = symbols("alpha, beta, gamma", real=True)
      D = wigner_d(half, alpha, beta, gamma)
      assert D[0, 0] == exp(I * alpha / 2) * exp(I * gamma / 2) * cos(
          beta / 2
      )
      assert D[0, 1] == exp(I * alpha / 2) * exp(-I * gamma / 2) * sin(
          beta / 2
      )
      assert D[1, 0] == -exp(-I * alpha / 2) * exp(I * gamma / 2) * sin(
          beta / 2
      )
      assert D[1, 1] == exp(-I * alpha / 2) * exp(-I * gamma / 2) * cos(
          beta / 2
      )
  
      # Test Y_{n mi}(g*x)=\sum_{mj}D^n_{mi mj}*Y_{n mj}(x)
      theta, phi = symbols("theta phi", real=True)
      v = Matrix([Ynm(1, mj, theta, phi) for mj in range(1, -2, -1)])
      w = wigner_d(1, -pi / 2, pi / 2, -pi / 2) @ v.subs(
          {theta: pi / 4, phi: pi}
      )
      w_ = v.subs({theta: pi / 2, phi: pi / 4})
      assert (
          w.expand(func=True).as_real_imag()
          == w_.expand(func=True).as_real_imag()
      )
  
file_path: sympy/sympy/physics/tests/test_clebsch_gordan.py
imports: from sympy.core.numbers import I, pi, Rational
  from sympy.core.singleton import S
  from sympy.core.symbol import symbols
  from sympy.functions.elementary.exponential import exp
  from sympy.functions.elementary.miscellaneous import sqrt
  from sympy.functions.elementary.trigonometric import cos, sin
  from sympy.functions.special.spherical_harmonics import Ynm
  from sympy.matrices.dense import Matrix
  from sympy.physics.wigner import clebsch_gordan, wigner_9j, wigner_6j, gaunt, real_gaunt, racah, dot_rot_grad_Ynm, wigner_3j, wigner_d_small, wigner_d
  from sympy.testing.pytest import raises
label_desc: Use image node_id 8 for calling a global function with example usage: test_wigner_d() without return types