code: def test_real_sh_descoteaux_from_index():
      # Tests derived from tables in
      # https://en.wikipedia.org/wiki/Table_of_spherical_harmonics
      # where real spherical harmonic $Y^m_n$ is defined to be:
      #    Real($Y^m_n$) * sqrt(2) if m > 0
      #    $Y^m_n$                 if m == 0
      #    Imag($Y^m_n$) * sqrt(2) if m < 0
  
      rsh = real_sh_descoteaux_from_index
      pi = np.pi
      sqrt = np.sqrt
      sin = np.sin
      cos = np.cos
  
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
  
          assert_array_almost_equal(rsh(0, 0, 0, 0), 0.5 / sqrt(pi))
          assert_array_almost_equal(
              rsh(-2, 2, pi / 5, pi / 3),
              0.25
              * sqrt(15.0 / (2.0 * pi))
              * (sin(pi / 5.0)) ** 2.0
              * cos(0 + 2.0 * pi / 3)
              * sqrt(2),
          )
          assert_array_almost_equal(
              rsh(2, 2, pi / 5, pi / 3),
              -1
              * 0.25
              * sqrt(15.0 / (2.0 * pi))
              * (sin(pi / 5.0)) ** 2.0
              * sin(0 - 2.0 * pi / 3)
              * sqrt(2),
          )
          assert_array_almost_equal(
              rsh(-2, 2, pi / 2, pi),
              0.25
              * sqrt(15 / (2.0 * pi))
              * cos(2.0 * pi)
              * sin(pi / 2.0) ** 2.0
              * sqrt(2),
          )
          assert_array_almost_equal(
              rsh(2, 4, pi / 3.0, pi / 4.0),
              -1
              * (3.0 / 8.0)
              * sqrt(5.0 / (2.0 * pi))
              * sin(0 - 2.0 * pi / 4.0)
              * sin(pi / 3.0) ** 2.0
              * (7.0 * cos(pi / 3.0) ** 2.0 - 1)
              * sqrt(2),
          )
          assert_array_almost_equal(
              rsh(-4, 4, pi / 6.0, pi / 8.0),
              (3.0 / 16.0)
              * sqrt(35.0 / (2.0 * pi))
              * cos(0 + 4.0 * pi / 8.0)
              * sin(pi / 6.0) ** 4.0
              * sqrt(2),
          )
          assert_array_almost_equal(
              rsh(4, 4, pi / 6.0, pi / 8.0),
              -1
              * (3.0 / 16.0)
              * sqrt(35.0 / (2.0 * pi))
              * sin(0 - 4.0 * pi / 8.0)
              * sin(pi / 6.0) ** 4.0
              * sqrt(2),
          )
  
      aa = np.ones((3, 1, 1, 1))
      bb = np.ones((1, 4, 1, 1))
      cc = np.ones((1, 1, 5, 1))
      dd = np.ones((1, 1, 1, 6))
  
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
  
          assert_equal(rsh(aa, bb, cc, dd).shape, (3, 4, 5, 6))
  
imports: import warnings
  import numpy
  import numpy.linalg
  import numpy.testing
  from dipy.testing import assert_true
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_equal, assert_raises
  from scipy.special import sph_harm
  from dipy.core.sphere import hemi_icosahedron, Sphere
  from dipy.core.gradients import gradient_table
  from dipy.core.interpolation import NearestNeighborInterpolator
  from dipy.sims.voxel import single_tensor
  from dipy.direction.peaks import peak_directions
  from dipy.reconst.shm import sf_to_sh, sh_to_sf
  from dipy.sims.voxel import multi_tensor_odf
  from dipy.data import mrtrix_spherical_functions
  from dipy.reconst import odf
  from dipy.reconst.shm import real_sh_descoteaux_from_index, real_sym_sh_basis, real_sym_sh_mrtrix, real_sh_descoteaux, real_sh_tournier, sph_harm_ind_list, order_from_ncoef, OpdtModel, normalize_data, hat, lcr_matrix, smooth_pinv, bootstrap_data_array, bootstrap_data_voxel, ResidualBootstrapWrapper, CsaOdfModel, QballModel, SphHarmFit, spherical_harmonics, anisotropic_power, calculate_max_order, sh_to_sf_matrix, gen_dirac, convert_sh_to_full_basis, convert_sh_from_legacy, convert_sh_to_legacy, convert_sh_descoteaux_tournier, descoteaux07_legacy_msg, tournier07_legacy_msg
label_desc: Use image node_id 3 for calling a global function with example usage: test_real_sh_descoteaux_from_index() without return types