docs: def matrix_element(ji, fi, mi, jj, fj, mj,
                     II, reduced_matrix_element, q=None,
                     numeric=True, convention=1):
      r"""Calculate a matrix element of the electric dipole (in the helicity
      basis).
  
      We calculate the matrix element for the cyclical transition of the D2 line
      in Rb 87.
  
      >>> from sympy import symbols
      >>> red = symbols("r", positive=True)
      >>> half = 1/Integer(2)
      >>> II = 3*half
      >>> matrix_element(3*half, 3, 3, half, 2, 2, II, red, q=1, numeric=False)
      r/2
  
      If no polarization component is specified, all are returned.
  
      >>> matrix_element(3*half, 3, 3, half, 2, 2, II, red, numeric=False)
      [0, 0, r/2]
  
      """
      if q is None:
          return [matrix_element(ji, fi, mi, jj, fj, mj,
                                 II, reduced_matrix_element, qi,
                                 numeric=numeric, convention=convention)
                  for qi in [-1, 0, 1]]
      if numeric:
          from numpy import sqrt as numsqrt
          sqrt = numsqrt
      else:
          from sympy import sqrt as symsqrt
          sqrt = symsqrt
  
      rpij = (-1)**(fi-mi)
      rpij *= wigner_3j(fi, 1, fj, -mi, q, mj)
  
      rpij *= (-1)**(fj+ji+1+II)
      rpij *= sqrt(2*fj+1)
      rpij *= sqrt(2*fi+1)
      rpij *= wigner_6j(ji, jj, 1, fj, fi, II)
      rpij *= reduced_matrix_element
  
      if convention == 2:
          rpij = rpij * sqrt(2*ji+1)
      if numeric:
          rpij = float(rpij)
      return rpij