code: def test_specification(
      endog,
      exog,
      p,
      d,
      q,
      P,
      D,
      Q,
      s,
      enforce_stationarity,
      enforce_invertibility,
      concentrate_scale,
  ):
      # Assumptions:
      # - p, q, P, Q are either integers or lists of non-consecutive integers
      #   (i.e. we are not testing boolean lists or consecutive lists here, which
      #   should be tested in the `standardize_lag_order` tests)
  
      # Construct the specification
      if isinstance(p, list):
          k_ar_params = len(p)
          max_ar_order = p[-1]
      else:
          k_ar_params = max_ar_order = p
  
      if isinstance(q, list):
          k_ma_params = len(q)
          max_ma_order = q[-1]
      else:
          k_ma_params = max_ma_order = q
  
      if isinstance(P, list):
          k_seasonal_ar_params = len(P)
          max_seasonal_ar_order = P[-1]
      else:
          k_seasonal_ar_params = max_seasonal_ar_order = P
  
      if isinstance(Q, list):
          k_seasonal_ma_params = len(Q)
          max_seasonal_ma_order = Q[-1]
      else:
          k_seasonal_ma_params = max_seasonal_ma_order = Q
  
      # Get endog / exog
      nobs = (
          d
          + D * s
          + max(
              3 * max_ma_order + 1,
              3 * max_seasonal_ma_order * s + 1,
              max_ar_order,
              max_seasonal_ar_order * s,
          )
          + 1
      )
  
      if endog is True:
          endog = np.arange(nobs) * 1.0
      elif isinstance(endog, str):
          endog = pd.Series(np.arange(nobs) * 1.0, name=endog)
      elif endog is not None:
          raise ValueError("Invalid `endog` in test setup.")
  
      if isinstance(exog, int):
          exog_names = ["x%d" % (i + 1) for i in range(exog)]
          exog = np.arange(nobs * len(exog_names)).reshape(
              nobs, len(exog_names)
          )
      elif isinstance(exog, list):
          exog_names = exog
          exog = np.arange(nobs * len(exog_names)).reshape(
              nobs, len(exog_names)
          )
          exog = pd.DataFrame(exog, columns=exog_names)
      elif exog is None:
          exog_names = []
      else:
          raise ValueError("Invalid `exog` in test setup.")
  
      # Setup args, kwargs
      args = ((p, d, q), (P, D, Q, s))
      kwargs = {
          "enforce_stationarity": enforce_stationarity,
          "enforce_invertibility": enforce_invertibility,
          "concentrate_scale": concentrate_scale,
      }
      properties_kwargs = kwargs.copy()
      is_ar_consecutive = (
          not isinstance(p, list) and max_seasonal_ar_order == 0
      )
      is_ma_consecutive = (
          not isinstance(q, list) and max_seasonal_ma_order == 0
      )
      properties_kwargs.update(
          {
              "is_ar_consecutive": is_ar_consecutive,
              "is_ma_consecutive": is_ma_consecutive,
              "exog_names": exog_names,
              "ar_names": [
                  "ar.L%d" % i
                  for i in (
                      p if isinstance(p, list) else range(1, p + 1)
                  )
              ],
              "ma_names": [
                  "ma.L%d" % i
                  for i in (
                      q if isinstance(q, list) else range(1, q + 1)
                  )
              ],
              "seasonal_ar_names": [
                  "ar.S.L%d" % (i * s)
                  for i in (
                      P if isinstance(P, list) else range(1, P + 1)
                  )
              ],
              "seasonal_ma_names": [
                  "ma.S.L%d" % (i * s)
                  for i in (
                      Q if isinstance(Q, list) else range(1, Q + 1)
                  )
              ],
          }
      )
  
      methods_kwargs = kwargs.copy()
      methods_kwargs.update(
          {
              "exog_params": np.arange(len(exog_names)),
              "ar_params": (
                  []
                  if k_ar_params == 0
                  else constrain(np.arange(k_ar_params) / 10)
              ),
              "ma_params": (
                  []
                  if k_ma_params == 0
                  else constrain((np.arange(k_ma_params) + 10) / 100)
              ),
              "seasonal_ar_params": (
                  []
                  if k_seasonal_ar_params == 0
                  else constrain(np.arange(k_seasonal_ar_params) - 4)
              ),
              "seasonal_ma_params": (
                  []
                  if k_seasonal_ma_params == 0
                  else constrain(
                      (np.arange(k_seasonal_ma_params) - 10) / 100
                  )
              ),
              "sigma2": [] if concentrate_scale else 2.3424,
          }
      )
  
      # Test the spec created with order, seasonal_order
      spec = specification.SARIMAXSpecification(
          endog,
          exog=exog,
          order=(p, d, q),
          seasonal_order=(P, D, Q, s),
          enforce_stationarity=enforce_stationarity,
          enforce_invertibility=enforce_invertibility,
          concentrate_scale=concentrate_scale,
      )
  
      check_attributes(spec, *args, **kwargs)
      check_properties(spec, *args, **properties_kwargs)
      check_methods(spec, *args, **methods_kwargs)
  
      # Test the spec created with ar_order, etc.
      spec = specification.SARIMAXSpecification(
          endog,
          exog=exog,
          ar_order=p,
          diff=d,
          ma_order=q,
          seasonal_ar_order=P,
          seasonal_diff=D,
          seasonal_ma_order=Q,
          seasonal_periods=s,
          enforce_stationarity=enforce_stationarity,
          enforce_invertibility=enforce_invertibility,
          concentrate_scale=concentrate_scale,
      )
  
      check_attributes(spec, *args, **kwargs)
      check_properties(spec, *args, **properties_kwargs)
      check_methods(spec, *args, **methods_kwargs)
  
file_path: statsmodels/statsmodels/tsa/arima/tests/test_specification.py
imports: import numpy
  import pandas
  import pytest
  from numpy.testing import assert_equal, assert_allclose, assert_raises
  from statsmodels.tsa.statespace.tools import constrain_stationary_univariate, unconstrain_stationary_univariate
  from statsmodels.tsa.arima import specification
label_desc: Use image node_id 5 for calling a global function with example usage: test_specification(endog, exog, p, d, q, P, D, Q, s, enforce_stationarity, enforce_invertibility, concentrate_scale) without return types