code: def test_zero_mean_forecast(self):
      am = arch_model(self.zero_mean, mean="Zero", vol="Constant")
      res = am.fit()
      fcast = res.forecast(res.params, horizon=3)
      alt_fcast = res.forecast(horizon=3)
      assert_frame_equal(fcast.mean, alt_fcast.mean)
      assert_frame_equal(fcast.variance, alt_fcast.variance)
      assert_frame_equal(
          fcast.residual_variance, alt_fcast.residual_variance
      )
  
      with pytest.raises(ValueError, match="horizon must"):
          res.forecast(res.params, horizon=3.0)
      with pytest.raises(ValueError, match="horizon must"):
          res.forecast(res.params, horizon=-1)
      with pytest.raises(ValueError, match="horizon must"):
          res.forecast(res.params, horizon="3")
  
      fcast_reindex = res.forecast(res.params, horizon=3, reindex=True)
      assert_frame_equal(fcast.mean, fcast_reindex.mean.iloc[-1:])
      assert_frame_equal(
          fcast.variance, fcast_reindex.variance.iloc[-1:]
      )
      assert_frame_equal(
          fcast.residual_variance,
          fcast_reindex.residual_variance.iloc[-1:],
      )
      assert fcast_reindex.mean.shape[0] == self.zero_mean.shape[0]
  
      assert np.all(np.asarray(np.isnan(fcast.mean[:-1])))
      assert np.all(np.asarray(np.isnan(fcast.variance[:-1])))
      assert np.all(np.asarray(np.isnan(fcast.residual_variance[:-1])))
  
      params = np.asarray(res.params)
      assert np.all(0.0 == fcast.mean.iloc[-1])
      assert_allclose(fcast.variance.iloc[-1], np.ones(3) * params[0])
      assert_allclose(
          fcast.residual_variance.iloc[-1], np.ones(3) * params[0]
      )
  
      res = am.fit(last_obs=500)
      params = np.asarray(res.params)
      fcast = res.forecast(horizon=3)
      assert fcast.mean.shape == (501, 3)
      assert fcast.variance.shape == (501, 3)
      assert fcast.residual_variance.shape == (501, 3)
      assert np.all(np.asarray(np.isfinite(fcast.mean)))
      assert np.all(np.asarray(np.isfinite(fcast.variance)))
      assert np.all(np.asarray(np.isfinite(fcast.residual_variance)))
  
      assert np.all(np.asarray(0.0 == fcast.mean))
      assert_allclose(fcast.variance, np.ones((501, 3)) * params[0])
      assert_allclose(
          fcast.residual_variance, np.ones((501, 3)) * params[0]
      )
      with pytest.raises(
          ValueError, match="horizon must be an integer >= 1"
      ):
          res.forecast(horizon=0)
  
imports: import datetime
  from itertools import product
  import numpy
  from numpy.random import RandomState
  from numpy.testing import assert_allclose
  import pandas
  from pandas.testing import assert_frame_equal
  import pytest
  from arch.data import sp500
  from arch.tests.univariate.test_variance_forecasting import preserved_state
  from arch.univariate import APARCH, ARX, EGARCH, FIGARCH, GARCH, HARCH, HARX, ConstantMean, ConstantVariance, EWMAVariance, MIDASHyperbolic, RiskMetrics2006, ZeroMean, arch_model
  from arch.univariate.mean import _ar_forecast, _ar_to_impulse
label_desc: Use image node_id 4 for calling the TestForecasting obj's underlying member method code with example usage: obj.test_zero_mean_forecast() without return types