code: def test_aparch_delta(setup):
      delta = 0.7
      aparch = APARCH(delta=0.7)
      sv = aparch.starting_values(setup.resids)
      assert_equal(sv.shape[0], aparch.num_params)
  
      bounds = aparch.bounds(setup.resids)
      upper = max(
          np.mean(setup.resids**2.0),
          np.mean(np.abs(setup.resids) ** 0.5),
      )
      assert_equal(bounds[0], (0.0, 10.0 * upper))
      assert_equal(bounds[1], (0.0, 1.0))
      assert_equal(bounds[2], (-0.9997, 0.9997))
      assert_equal(bounds[3], (0.0, 1.0))
      backcast = aparch.backcast(setup.resids)
      w = 0.94 ** np.arange(75)
      assert_almost_equal(
          backcast, np.sum((setup.resids[:75] ** 2) * (w / w.sum()))
      )
      var_bounds = aparch.variance_bounds(setup.resids)
      parameters = np.array([0.1, 0.1, -0.5, 0.8])
      aparch.compute_variance(
          parameters, setup.resids, setup.sigma2, backcast, var_bounds
      )
      cond_var_direct = np.zeros_like(setup.sigma2)
      rec_parameters = np.array([0.1, 0.1, -0.5, 0.8, delta])
      rec.aparch_recursion(
          rec_parameters,
          setup.resids,
          np.abs(setup.resids),
          cond_var_direct,
          cond_var_direct.copy(),
          1,
          1,
          1,
          setup.t,
          backcast,
          var_bounds,
      )
      assert_allclose(setup.sigma2, cond_var_direct)
  
      a, b = aparch.constraints()
      a_target = np.array(
          [
              [1, 0, 0, 0],
              [0, 1, 0, 0],
              [0, 0, 1, 0],
              [0, 0, -1, 0],
              [0, 0, 0, 1],
              [0, -1, 0, -1],
          ]
      )
      b_target = np.array([0.0, 0.0, -0.9997, -0.9997, 0.0, -1.0])
      assert_array_equal(a, a_target)
      assert_array_equal(b, b_target)
      state = setup.rng.get_state()
      rng = Normal(seed=RandomState())
      rng.generator.set_state(state)
      sim_data = aparch.simulate(parameters, setup.t, rng.simulate([]))
      setup.rng.set_state(state)
      e = setup.rng.standard_normal(setup.t + 500)
      initial_value = 1.0
      sigma_delta = np.zeros(setup.t + 500)
      sigma2 = np.zeros(setup.t + 500)
      data = np.zeros(setup.t + 500)
      for t in range(setup.t + 500):
          sigma_delta[t] = parameters[0]
          shock = initial_value if t == 0 else np.abs(data[t - 1])
          shock -= 0 if t == 0 else parameters[2] * data[t - 1]
          sigma_delta[t] += parameters[1] * shock**delta
          lagged_value = initial_value if t == 0 else sigma_delta[t - 1]
          sigma_delta[t] += parameters[3] * lagged_value
          sigma2[t] = sigma_delta[t] ** (2 / delta)
          data[t] = e[t] * np.sqrt(sigma2[t])
      data = data[500:]
      sigma2 = sigma2[500:]
      assert_almost_equal(data / sim_data[0], np.ones_like(data))
      assert_almost_equal(sigma2 / sim_data[1], np.ones_like(sigma2))
  
      names = aparch.parameter_names()
      names_target = ["omega", "alpha[1]", "gamma[1]", "beta[1]"]
      assert_equal(names, names_target)
  
      assert isinstance(aparch.__str__(), str)
      assert "p: 1, o: 1, q: 1, delta: 0.7" in str(aparch)
      txt = aparch.__repr__()
      assert str(hex(id(aparch))) in txt
  
      assert_equal(aparch.name, "APARCH")
      assert not aparch._est_delta
      assert_equal(aparch.num_params, 4)
      assert_equal(aparch._delta, 0.7)
      assert aparch.p == aparch.o == aparch.q == 1
  
imports: import types
  from typing import NamedTuple
  import warnings
  import numpy
  from numpy.random import RandomState
  from numpy.testing import assert_allclose, assert_almost_equal, assert_array_equal, assert_equal
  import pytest
  from scipy.special import gamma, gammaln
  from arch.univariate import ZeroMean
  from arch.univariate.distribution import Normal, SkewStudent, StudentsT
  import arch.univariate.recursions_python
  from arch.univariate.volatility import APARCH, ARCH, EGARCH, FIGARCH, GARCH, HARCH, ConstantVariance, EWMAVariance, FixedVariance, MIDASHyperbolic, RiskMetrics2006
  from arch.utility.exceptions import InitialValueWarning
label_desc: Use image node_id 34 for calling a global function with example usage: test_aparch_delta(setup) without return types