code: def test_boot_pmf():
      # This tests the local model used for the bootstrapping.
      hsph_updated = HemiSphere.from_sphere(unit_icosahedron)
      vertices = hsph_updated.vertices
      bvecs = vertices
      bvals = np.ones(len(vertices)) * 1000
      bvecs = np.insert(bvecs, 0, np.array([0, 0, 0]), axis=0)
      bvals = np.insert(bvals, 0, 0)
      gtab = gradient_table(bvals, bvecs)
      voxel = single_tensor(gtab)
      data = np.tile(voxel, (3, 3, 3, 1))
      point = np.array([1.0, 1.0, 1.0])
      tensor_model = TensorModel(gtab)
      response = (np.array([1.5e3, 0.3e3, 0.3e3]), 1)
  
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=shm.descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          boot_dg = BootDirectionGetter(
              data,
              model=tensor_model,
              max_angle=60,
              sphere=hsph_updated,
          )
      no_boot_pmf = boot_dg.get_pmf_no_boot(point)
      model_pmf = tensor_model.fit(voxel).odf(hsph_updated)
  
      npt.assert_equal(len(hsph_updated.vertices), no_boot_pmf.shape[0])
      npt.assert_array_almost_equal(no_boot_pmf, model_pmf)
  
      # test model spherical harmonic order different than bootstrap order
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always", category=UserWarning)
          warnings.simplefilter(
              "always", category=PendingDeprecationWarning
          )
          csd_model = ConstrainedSphericalDeconvModel(
              gtab, response, sh_order=6
          )
          # Tests that the first caught warning comes from the CSD model
          # constructor
          npt.assert_(issubclass(w[0].category, UserWarning))
          npt.assert_(
              "Number of parameters required " in str(w[0].message)
          )
  
          # Tests that additional warnings are raised for outdated SH basis
          npt.assert_(len(w) > 1)
  
          boot_dg_sh4 = BootDirectionGetter(
              data,
              model=csd_model,
              max_angle=60,
              sphere=hsph_updated,
              sh_order=4,
          )
          pmf_sh4 = boot_dg_sh4.get_pmf(point)
          npt.assert_equal(len(hsph_updated.vertices), pmf_sh4.shape[0])
          npt.assert_(np.sum(pmf_sh4.shape) > 0)
  
          boot_dg_sh8 = BootDirectionGetter(
              data,
              model=csd_model,
              max_angle=60,
              sphere=hsph_updated,
              sh_order=8,
          )
          pmf_sh8 = boot_dg_sh8.get_pmf(point)
          npt.assert_equal(len(hsph_updated.vertices), pmf_sh8.shape[0])
          npt.assert_(np.sum(pmf_sh8.shape) > 0)
  
      # test b_tol parameter
      bvals[-2] = 1100
      gtab = gradient_table(bvals, bvecs)
      tensor_model = TensorModel(gtab)
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=shm.descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          npt.assert_raises(
              ValueError,
              BootDirectionGetter,
              data,
              tensor_model,
              60,
              hsph_updated,
              6,
              20,
          )
          npt.assert_raises(
              ValueError,
              BootDirectionGetter,
              data,
              tensor_model,
              60,
              hsph_updated,
              6,
              -1,
          )
  
file_path: dipy/dipy/direction/tests/test_bootstrap_direction_getter.py
imports: import warnings
  import numpy
  import numpy.testing
  from dipy.core.geometry import cart2sphere
  from dipy.core.gradients import gradient_table
  from dipy.core.sphere import HemiSphere, unit_icosahedron
  from dipy.data import get_sphere, get_fnames
  from dipy.direction.bootstrap_direction_getter import BootDirectionGetter
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.reconst import dti, shm
  from dipy.reconst.csdeconv import ConstrainedSphericalDeconvModel, TensorModel
  from dipy.sims.voxel import multi_tensor, single_tensor
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 4 for calling a global function with example usage: test_boot_pmf() without return types