code: def test_summary():
      """Tests `Detector` class summary method."""
      # Tests summary with NormalDetector
      size = 500
      np.random.seed(1317)
      y = np.random.normal(loc=0.0, scale=1.0, size=size)
      df = pd.DataFrame({"y": y})
      anomaly_percent_dict = {"range": (4, 6), "penalty": -1.0}
  
      detector = NormalDetector(
          value_col="y", anomaly_percent_dict=anomaly_percent_dict
      )
      detector.fit(Data(df=df))
  
      summary = detector.summary()
      assert "NormalDetector" in summary
      assert "Anomaly Duration" not in summary
      assert "Optimal Parameters" in summary
  
      # Tests error when `Detector` is not fitted.
      detector = Detector()
      with pytest.raises(ValueError, match="No data to summarize."):
          detector.summary()
  
imports: import numpy
  import pandas
  import pytest
  from scipy import stats
  from greykite.common.constants import PREDICTED_ANOMALY_COL
  from greykite.common.viz.timeseries_annotate import plot_lines_markers
  from greykite.detection.common.ad_evaluation import f1_score
  from greykite.detection.detector.data import DetectorData
  from greykite.detection.detector.detector import Detector
  from greykite.detection.detector.detector import build_anomaly_percent_reward
  from greykite.detection.detector.optimizer import CalcResult
  from greykite.detection.detector.reward import Reward
label_desc: Use image node_id 5 for calling a global function with example usage: test_summary() without return types