code: def test_local_maxima():
      sphere = default_sphere
      vertices, faces = sphere.vertices, sphere.faces
      edges = unique_edges(faces)
  
      # Check that the first peak is == max(odf)
      odf = abs(vertices.sum(-1))
      peak_values, peak_index = local_maxima(odf, edges)
      npt.assert_equal(max(odf), peak_values[0])
      npt.assert_equal(max(odf), odf[peak_index[0]])
  
      # Create an artificial odf with a few peaks
      odf = np.zeros(len(vertices))
      odf[1] = 1.0
      odf[143] = 143.0
      odf[361] = 361.0
      peak_values, peak_index = local_maxima(odf, edges)
      npt.assert_array_equal(peak_values, [361, 143, 1])
      npt.assert_array_equal(peak_index, [361, 143, 1])
  
      # Check that neighboring points can both be peaks
      odf = np.zeros(len(vertices))
      point1, point2 = edges[0]
      odf[[point1, point2]] = 1.0
      peak_values, peak_index = local_maxima(odf, edges)
      npt.assert_array_equal(peak_values, [1.0, 1.0])
      npt.assert_(point1 in peak_index)
      npt.assert_(point2 in peak_index)
  
      # Repeat with a hemisphere
      hemisphere = HemiSphere(xyz=vertices, faces=faces)
      vertices, edges = hemisphere.vertices, hemisphere.edges
  
      # Check that the first peak is == max(odf)
      odf = abs(vertices.sum(-1))
      peak_values, peak_index = local_maxima(odf, edges)
      npt.assert_equal(max(odf), peak_values[0])
      npt.assert_equal(max(odf), odf[peak_index[0]])
  
      # Create an artificial odf with a few peaks
      odf = np.zeros(len(vertices))
      odf[1] = 1.0
      odf[143] = 143.0
      odf[300] = 300.0
      peak_value, peak_index = local_maxima(odf, edges)
      npt.assert_array_equal(peak_value, [300, 143, 1])
      npt.assert_array_equal(peak_index, [300, 143, 1])
  
      # Check that neighboring points can both be peaks
      odf = np.zeros(len(vertices))
      point1, point2 = edges[0]
      odf[[point1, point2]] = 1.0
      peak_values, peak_index = local_maxima(odf, edges)
      npt.assert_array_equal(peak_values, [1.0, 1.0])
      npt.assert_(point1 in peak_index)
      npt.assert_(point2 in peak_index)
  
      # Should raise an error if odf has nans
      odf[20] = np.nan
      npt.assert_raises(ValueError, local_maxima, odf, edges)
  
      # Should raise an error if edge values are too large to index odf
      edges[0, 0] = 9999
      odf[20] = 0
      npt.assert_raises(IndexError, local_maxima, odf, edges)
  
file_path: dipy/dipy/reconst/tests/test_peak_finding.py
imports: import numpy
  import numpy.testing
  from dipy.reconst.recspeed import local_maxima, remove_similar_vertices, search_descending
  from dipy.data import default_sphere
  from dipy.core.sphere import unique_edges, HemiSphere
label_desc: Use image node_id 1 for calling a global function with example usage: test_local_maxima() without return types