code: def test_harch_update(self):
      nobs, resids = self.nobs, self.resids
      sigma2, backcast = self.sigma2, self.backcast
  
      parameters = np.array([0.1, 0.4, 0.3, 0.2])
      lags = np.array([1, 5, 22], dtype=np.int32)
      rec.harch_recursion(
          parameters,
          resids,
          sigma2,
          lags,
          nobs,
          backcast,
          self.var_bounds,
      )
      sigma2_direct = sigma2.copy()
      sigma2[:] = np.nan
      for t in range(nobs):
          recpy.harch_core_python(
              t,
              parameters,
              resids,
              sigma2,
              lags,
              backcast,
              self.var_bounds,
          )
      assert_allclose(sigma2, sigma2_direct)
  
      for t in range(nobs):
          recpy.harch_core(
              t,
              parameters,
              resids,
              sigma2,
              lags,
              backcast,
              self.var_bounds,
          )
      assert_allclose(sigma2, sigma2_direct)
  
      for t in range(nobs):
          rec.harch_core(
              t,
              parameters,
              resids,
              sigma2,
              lags,
              backcast,
              self.var_bounds,
          )
      assert_allclose(sigma2, sigma2_direct)
  
      sigma2[:] = np.nan
      hu = recpy.HARCHUpdater(lags)
      hu.initialize_update(parameters, backcast, nobs)
      for t in range(nobs):
          hu.update(t, parameters, resids, sigma2, self.var_bounds)
          if t == nobs // 2:
              hu = pickle.loads(pickle.dumps(hu))
      hu.initialize_update(parameters, backcast, nobs)
      assert_allclose(sigma2, sigma2_direct)
  
      sigma2[:] = np.nan
      hu = rec.HARCHUpdater(lags)
      hu.initialize_update(parameters, backcast, nobs)
      for t in range(nobs):
          hu._update_tester(
              t, parameters, resids, sigma2, self.var_bounds
          )
          if t == nobs // 2:
              hu = pickle.loads(pickle.dumps(hu))
      hu.initialize_update(parameters, backcast, nobs)
      assert_allclose(sigma2, sigma2_direct)
  
imports: import os
  import pickle
  import timeit
  import types
  import numpy
  from numpy.random import RandomState
  from numpy.testing import assert_allclose, assert_almost_equal
  import pytest
  from scipy.special import gamma
  import arch.univariate.recursions_python
  from arch.univariate.volatility import RiskMetrics2006
label_desc: Use image node_id 5 for calling the TestRecursions obj's underlying member method code with example usage: obj.test_harch_update() without return types