code: def test_oob_for_issue_28():
      # Continuation of above: can we do one with an X array, too?
      xreg = rs.rand(hr.shape[0], 4)
      arima = ARIMA(
          order=(2, 1, 2), suppress_warnings=True, out_of_sample_size=10
      ).fit(y=hr, X=xreg)
  
      oob = arima.oob()
      assert not np.isnan(oob)
  
      # Assert that the endog shapes match. First is equal to the original,
      # and the second is the differenced array
      assert np.allclose(arima.arima_res_.data.endog, hr, rtol=1e-2)
      assert arima.arima_res_.model.endog.shape[0] == hr.shape[0]
  
      # Now assert the same for X
      assert np.allclose(arima.arima_res_.data.exog, xreg, rtol=1e-2)
      assert arima.arima_res_.model.exog.shape[0] == xreg.shape[0]
  
      # Compare the OOB score to an equivalent fit on data - 10 obs, but
      # without any OOB scoring, and we'll show that the OOB scoring in the
      # first IS in fact only applied to the first (train - n_out_of_bag)
      # samples
      arima_no_oob = ARIMA(
          order=(2, 1, 2), suppress_warnings=True, out_of_sample_size=0
      ).fit(y=hr[:-10], X=xreg[:-10, :])
  
      scoring = val.get_scoring_metric(arima_no_oob.scoring)
      preds = arima_no_oob.predict(n_periods=10, X=xreg[-10:, :])
      assert np.allclose(oob, scoring(hr[-10:], preds), rtol=1e-2)
  
      # Show that the model parameters are not the same because the model was
      # updated.
      xreg_test = rs.rand(5, 4)
      assert not np.allclose(
          arima.params(), arima_no_oob.params(), rtol=1e-2
      )
  
      # Now assert on the forecast differences.
      with_oob_forecasts = arima.predict(n_periods=5, X=xreg_test)
      no_oob_forecasts = arima_no_oob.predict(n_periods=5, X=xreg_test)
  
      with pytest.raises(AssertionError):
          assert_array_almost_equal(
              with_oob_forecasts, no_oob_forecasts
          )
  
      # But after we update the no_oob model with the latest data, we should
      # be producing the same exact forecasts
  
      # First, show we'll fail if we try to add observations with no X
      with pytest.raises(ValueError):
          arima_no_oob.update(hr[-10:], None)
  
      # Also show we'll fail if we try to add mis-matched shapes of data
      with pytest.raises(ValueError):
          arima_no_oob.update(hr[-10:], xreg_test)
  
      # Show we fail if we try to add observations with a different dim X
      with pytest.raises(ValueError):
          arima_no_oob.update(hr[-10:], xreg_test[:, :2])
  
      # Actually add them now, and compare the forecasts (should be the same)
      arima_no_oob.update(hr[-10:], xreg[-10:, :])
      assert np.allclose(
          with_oob_forecasts,
          arima_no_oob.predict(n_periods=5, X=xreg_test),
          rtol=1e-2,
      )
  
imports: import numpy
  import pandas
  from pmdarima.arima import ARIMA, auto_arima, AutoARIMA, ARMAtoMA
  from pmdarima.arima import _validation
  from pmdarima.compat.pytest import pytest_error_str
  from pmdarima.datasets import load_lynx, load_wineind, load_heartrate
  from numpy.random import RandomState
  from numpy.testing import assert_array_almost_equal, assert_almost_equal, assert_allclose
  from statsmodels import api
  from sklearn.metrics import mean_squared_error
  import datetime
  import joblib
  import os
  import pickle
  import pytest
  import tempfile
  import time
label_desc: Use image node_id 10 for calling a global function with example usage: test_oob_for_issue_28() without return types