code: def test_peak_position_error():
      """Test simulation metrics."""
      src = read_source_spaces(src_fname)
      vert1 = [src[0]["vertno"][0:1], []]
      vert2 = [src[0]["vertno"][0:2], []]
      data1 = np.array([[1]])
      data2 = np.array([[1, 1.0]]).T
      stc_true = SourceEstimate(
          data1, vert1, 0, 0.002, subject="sample"
      )
      stc_est = SourceEstimate(data2, vert2, 0, 0.002, subject="sample")
      r_mean = 0.5 * (
          src[0]["rr"][vert2[0][0]] + src[0]["rr"][vert2[0][1]]
      )
      r_true = src[0]["rr"][vert2[0][0]]
      score = peak_position_error(
          stc_true, stc_est, src, per_sample=False
      )
  
      assert_allclose(score, norm(r_true - r_mean))
      with pytest.raises(
          ValueError, match="must contain only one dipole"
      ):
          peak_position_error(stc_est, stc_est, src)
  
      data2 = np.array([[0, 0.0]]).T
      stc_est = SourceEstimate(data2, vert2, 0, 0.002, subject="sample")
      score = peak_position_error(
          stc_true, stc_est, src, per_sample=False
      )
      assert_allclose(score, np.inf)
  
file_path: mne-python/mne/simulation/metrics/tests/test_metrics.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose
  from scipy.linalg import norm
  from mne import SourceEstimate, read_source_spaces
  from mne.datasets import testing
  from mne.simulation import metrics
  from mne.simulation.metrics import cosine_score, f1_score, peak_position_error, precision_score, recall_score, region_localization_error, roc_auc_score, spatial_deviation_error
label_desc: Use image node_id 8 for calling a global function with example usage: test_peak_position_error() without return types