code: def test_sp_to_use_using_auto_and_user_def():
      """Seasonal Period detection using Statistical tests (used on and after 3.0.0rc5).
      Also tests the user defined seasonal periods when used in conjunction with "auto".
      """
  
      exp = TSForecastingExperiment()
      data = get_data("airline", verbose=False)
  
      # 1.1 Auto Detection of Seasonal Period ----
      exp.setup(
          data=data,
          sp_detection="auto",
          verbose=False,
          session_id=42,
      )
      assert exp.candidate_sps == [12, 24, 36, 11, 48]
      assert exp.significant_sps == [12, 24, 36, 11, 48]
      assert exp.significant_sps_no_harmonics == [48, 36, 11]
      assert exp.all_sps_to_use == [12]
      assert exp.primary_sp_to_use == 12
  
      # 1.2 Auto Detection with multiple values allowed ----
      # 1.2.1 Multiple Seasonalities < tested and detected ----
      exp.setup(
          data=data,
          sp_detection="auto",
          num_sps_to_use=2,
          verbose=False,
          session_id=42,
      )
      assert exp.candidate_sps == [12, 24, 36, 11, 48]
      assert exp.significant_sps == [12, 24, 36, 11, 48]
      assert exp.significant_sps_no_harmonics == [48, 36, 11]
      assert exp.all_sps_to_use == [12, 24]
      assert exp.primary_sp_to_use == 12
  
      # 1.2.2 Multiple Seasonalities > tested and detected ----
      exp.setup(
          data=data,
          sp_detection="auto",
          num_sps_to_use=100,
          verbose=False,
          session_id=42,
      )
      assert exp.candidate_sps == [12, 24, 36, 11, 48]
      assert exp.significant_sps == [12, 24, 36, 11, 48]
      assert exp.significant_sps_no_harmonics == [48, 36, 11]
      assert exp.all_sps_to_use == [12, 24, 36, 11, 48]
      assert exp.primary_sp_to_use == 12
  
      # 2.0 Auto Detection based on length of data ----
      # 2.1 Length barely enough to detect seasonality (2*sp + 1)
      np.random.seed(42)
      sp = 60
      data = np.random.randint(0, 100, size=sp)
      data = pd.DataFrame(np.concatenate((np.tile(data, 2), [data[0]])))
      exp = TSForecastingExperiment()
      exp.setup(data=data)
      assert exp.primary_sp_to_use == sp
  
      # 2.2 Length just below threshold to detect seasonality (2*sp)
      exp = TSForecastingExperiment()
      exp.setup(data=data.iloc[: 2 * sp])
      assert exp.primary_sp_to_use < sp
  
      # 3.0 Overwritten by user defined seasonal period ----
      sp = 19
      # 3.1 ignore_seasonality_test = False (default)
      exp.setup(
          data=data,
          seasonal_period=sp,
          # ignore_seasonality_test=False,  # default
          sp_detection="auto",
          verbose=False,
          session_id=42,
      )
      assert exp.seasonal_period == sp
      # overridden to user_defined even through we pass "auto"
      assert exp.sp_detection == "user_defined"
      assert exp.ignore_seasonality_test is False
      assert exp.candidate_sps == [sp]
      assert exp.significant_sps == [1]
      assert exp.significant_sps_no_harmonics == [1]
      assert exp.all_sps_to_use == [1]
      assert exp.primary_sp_to_use == 1
  
      # 3.2 ignore_seasonality_test = True
      exp.setup(
          data=data,
          seasonal_period=sp,
          ignore_seasonality_test=True,
          sp_detection="auto",
          verbose=False,
          session_id=42,
      )
      assert exp.seasonal_period == sp
      # overridden to user_defined even through we pass "auto"
      assert exp.sp_detection == "user_defined"
      assert exp.ignore_seasonality_test is True
      assert exp.candidate_sps == [sp]
      assert exp.significant_sps == [sp]
      assert exp.significant_sps_no_harmonics == [sp]
      assert exp.all_sps_to_use == [sp]
      assert exp.primary_sp_to_use == sp
  
imports: import math
  import numpy
  import pandas
  import pytest
  from time_series_test_utils import _get_seasonal_values, _get_seasonal_values_alphanumeric, _return_data_seasonal_types_strictly_pos, _return_setup_args_raises, _return_splitter_args
  from pycaret.datasets import get_data
  from pycaret.time_series import TSForecastingExperiment
label_desc: Use image node_id 8 for calling a global function with example usage: test_sp_to_use_using_auto_and_user_def() without return types