code: def test_error_and_warnings():
      # Not 1-D array.
      with pytest.raises(
          ValueError, match="The input for scoring must be 1"
      ):
          precision_score(
              y_true=[[1, 2, 3], [4, 5, 6]],
              y_pred=[[1, 2, 3], [4, 5, 6]],
          )
  
      # Not equal length.
      with pytest.raises(
          ValueError, match="The input lengths must be the same, found"
      ):
          precision_score(y_true=[1, 2, 3], y_pred=[1, 2])
  
      # Warnings 1.
      with pytest.warns(
          UserWarning,
          match="The following categories do not appear in y_true column,",
      ):
          precision_score(y_true=[1, 2, 2], y_pred=[1, 2, 4])
  
      # Warnings 2.
      with pytest.warns(
          UserWarning,
          match="The following categories do not appear in y_pred column,",
      ):
          precision_score(y_true=[1, 2, 3], y_pred=[1, 2, 2])
  
imports: import numpy
  import pandas
  import pytest
  from greykite.detection.common.ad_evaluation import confusion_matrix
  from greykite.detection.common.ad_evaluation import f1_score
  from greykite.detection.common.ad_evaluation import informedness_statistic
  from greykite.detection.common.ad_evaluation import matthews_corrcoef
  from greykite.detection.common.ad_evaluation import precision_score
  from greykite.detection.common.ad_evaluation import range_based_precision_score
  from greykite.detection.common.ad_evaluation import range_based_recall_score
  from greykite.detection.common.ad_evaluation import recall_score
  from greykite.detection.common.ad_evaluation import soft_f1_score
  from greykite.detection.common.ad_evaluation import soft_precision_score
  from greykite.detection.common.ad_evaluation import soft_recall_score
label_desc: Use image node_id 8 for calling a global function with example usage: test_error_and_warnings() without return types