docstr: Test "sign test" algorithm with a threshold of 20%
docstr_tok: ["Test","``","sign","test","''","algorithm","with","a","threshold","of","20","%"]
code: def test_sign_test_algorithm_with_shift(self):
      """
      Test "sign test" algorithm with a threshold of 20%
      """
      bs = dict()
      bs.update((t, 1) for t in range(1, 100))
  
      # Simple tests
      algorithm_params = {
          "percent_threshold_upper": 10,
          "offset": 1,
          "scan_window": 24,
          "confidence": 0.01,
      }
      ts = dict(bs)
      # bigger than 10 percent but below bias
      ts.update((t, 1.2) for t in range(10, 34))
  
      # first no anomalies
      detector = AnomalyDetector(
          ts,
          baseline_time_series=bs,
          algorithm_name="sign_test",
          algorithm_params=algorithm_params,
      )
      anomalies = detector.get_anomalies()
  
      self.assertTrue(anomalies is not None)
      self.assertEqual(len(anomalies), 0)
  
      # Next one anomaly exactly equal to scan window
      # uses bias
      ts.update((t, 2.100001) for t in range(10, 34))
      detector = AnomalyDetector(
          ts,
          baseline_time_series=bs,
          algorithm_name="sign_test",
          algorithm_params=algorithm_params,
      )
      anomalies = detector.get_anomalies()
  
      self.assertTrue(anomalies is not None)
      self.assertEqual(len(anomalies), 1)
      anomaly = anomalies[0]
      s, e = anomaly.get_time_window()
  
      # note the anomaly is larger than scan window
      self.assertEqual(s, 4)
      self.assertEqual(e, 39)
  
      # score should be roughly 98.5
      self.assertGreater(anomaly.anomaly_score, 98)
      self.assertLess(anomaly.anomaly_score, 99)
  
      # anomaly below baseline but not below baseline with shift
      algorithm_params = {
          "percent_threshold_lower": -20,
          "offset": -0.1,
          "scan_window": 24,
      }
  
      ts.update((t, 0.799999) for t in range(10, 34))
      # no anomalies
      detector = AnomalyDetector(
          ts,
          baseline_time_series=bs,
          algorithm_name="sign_test",
          algorithm_params=algorithm_params,
      )
      anomalies = detector.get_anomalies()
  
      self.assertTrue(anomalies is not None)
      self.assertEqual(len(anomalies), 0)
  
      # lower the time series by 0.1
      ts.update((t, 0.699999) for t in range(10, 34))
  
      detector = AnomalyDetector(
          ts,
          baseline_time_series=bs,
          algorithm_name="sign_test",
          algorithm_params=algorithm_params,
      )
      anomalies = detector.get_anomalies()
      self.assertEqual(len(anomalies), 1)
      anomaly = anomalies[0]
      s, e = anomaly.get_time_window()
      self.assertEqual(s, 4)
      self.assertEqual(e, 39)
  
      # score should be roughly 98.5
      self.assertGreater(anomaly.anomaly_score, 98)
      self.assertLess(anomaly.anomaly_score, 99)
  
imports: import os
  import sys
  import unittest
  from luminol import exceptions
  from luminol.anomaly_detector import AnomalyDetector
  from luminol.modules.time_series import TimeSeries
  from luminol.algorithms.anomaly_detector_algorithms import AnomalyDetectorAlgorithm
label_desc: Use image node_id 6 for calling the TestAnomalyDetector obj's underlying member method code with example usage: obj.test_sign_test_algorithm_with_shift() without return types