code: def test_anisotropic_power():
      for n_coeffs in [6, 15, 28, 45, 66, 91]:
          for norm_factor in [0.0005, 0.00001]:
              # Create some really simple cases:
              coeffs = np.ones((3, n_coeffs))
              max_order = calculate_max_order(coeffs.shape[-1])
              # For the case where all coeffs == 1, the ap is simply log of the
              # number of even orders up to the maximal order:
              analytic = np.log(
                  len(range(2, max_order + 2, 2))
              ) - np.log(norm_factor)
  
              answers = [analytic] * 3
              apvals = anisotropic_power(
                  coeffs, norm_factor=norm_factor
              )
              assert_array_almost_equal(apvals, answers)
              # Test that this works for single voxel arrays as well:
              assert_array_almost_equal(
                  anisotropic_power(coeffs[1], norm_factor=norm_factor),
                  answers[1],
              )
  
      # Test that even when we look at an all-zeros voxel, this
      # avoids a log-of-zero warning:
      with warnings.catch_warnings(record=True) as w:
          assert_equal(anisotropic_power(np.zeros(6)), 0)
          assert len(w) == 0
  
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 20 for calling a global function with example usage: test_anisotropic_power() without return types