code: def test_dimension_selection_cv():
      # Tests the dimension selection using cross validation
      x1 = [1, 0, 0]
      x2 = [-1, 0, 0]
      x = np.random.randn(20, 3) * 0.1
      x[0::2] += x1
      x[1::2] += x2
      x = (x.T / np.sqrt(np.sum(x**2, 1))).T
  
      precision = 50.0
      sub = np.repeat(np.arange(10), 2)
      my_vmm = select_vmm_cv(
          list(range(1, 8)),
          precision,
          x,
          cv_index=sub,
          null_class=False,
          ninit=5,
      )
      z = np.argmax(my_vmm.responsibilities(x), 1)
      assert len(np.unique(z)) > 1
      assert len(np.unique(z)) < 4
  
file_path: nipy/nipy/algorithms/clustering/tests/test_vmm.py
imports: from unittest import skipIf
  import numpy
  from nibabel.optpkg import optional_package
  from ..von_mises_fisher_mixture import VonMisesMixture, select_vmm, select_vmm_cv, sphere_density
label_desc: Use image node_id 5 for calling a global function with example usage: test_dimension_selection_cv() without return types