code: def test_univariate_forecast(df):
      """Checks univariate forecast class"""
      # Without test_start_date
      forecast = UnivariateForecast(
          df,
          train_end_date=datetime.datetime(2018, 1, 2),
          test_start_date=None,
          forecast_horizon=2,
      )
  
      assert forecast.forecast_horizon == 2
      assert forecast.df_train.shape == (2, 6)
      assert forecast.df_test.shape == (2, 6)
      assert forecast.relative_error_tolerance is None
  
      # evaluation metrics
      enum = EvaluationMetricEnum.Correlation
      assert forecast.train_evaluation[enum.get_metric_name()] == 1.0
      assert forecast.test_evaluation[enum.get_metric_name()] == 1.0
      enum = EvaluationMetricEnum.MeanAbsoluteError
      assert forecast.train_evaluation[enum.get_metric_name()] == 1.0
      assert forecast.test_evaluation[enum.get_metric_name()] == 2.0
      enum = EvaluationMetricEnum.RootMeanSquaredError
      assert forecast.train_evaluation[
          enum.get_metric_name()
      ] == math.sqrt(2)
      assert forecast.test_evaluation[enum.get_metric_name()] == 2.0
      enum = EvaluationMetricEnum.MedianAbsoluteError
      assert forecast.train_evaluation[enum.get_metric_name()] == 1.0
      assert forecast.test_evaluation[enum.get_metric_name()] == 2.0
      enum = EvaluationMetricEnum.MeanAbsolutePercentError
      assert forecast.train_evaluation[enum.get_metric_name()] == 50.0
      assert forecast.test_evaluation[
          enum.get_metric_name()
      ] == pytest.approx(58.33333, 1e-4)
      assert forecast.train_evaluation[cst.R2_null_model_score] == -7.0
      assert forecast.test_evaluation[
          cst.R2_null_model_score
      ] == pytest.approx(0.058824, 1e-4)
      assert (
          forecast.train_evaluation[cst.FRACTION_OUTSIDE_TOLERANCE]
          is None
      )
      assert (
          forecast.test_evaluation[cst.FRACTION_OUTSIDE_TOLERANCE]
          is None
      )
      # validation metrics
      assert (
          forecast.train_evaluation[cst.PREDICTION_BAND_WIDTH] == 250.0
      )
      assert forecast.test_evaluation[cst.PREDICTION_BAND_WIDTH] == 87.5
      assert (
          forecast.train_evaluation[cst.PREDICTION_BAND_COVERAGE] == 0.5
      )
      assert (
          forecast.test_evaluation[cst.PREDICTION_BAND_COVERAGE] == 0.5
      )
      assert forecast.train_evaluation[cst.LOWER_BAND_COVERAGE] == 0.5
      assert forecast.test_evaluation[cst.LOWER_BAND_COVERAGE] == 0.0
      assert forecast.train_evaluation[cst.UPPER_BAND_COVERAGE] == 0.0
      assert forecast.test_evaluation[cst.UPPER_BAND_COVERAGE] == 0.5
      assert forecast.train_evaluation[
          cst.COVERAGE_VS_INTENDED_DIFF
      ] == pytest.approx(-0.45)
      assert forecast.test_evaluation[
          cst.COVERAGE_VS_INTENDED_DIFF
      ] == pytest.approx(-0.45)
  
      # With test_start_date, relative_error_tolerance
      with pytest.warns(UserWarning):
          forecast = UnivariateForecast(
              df,
              train_end_date=datetime.datetime(2018, 1, 2),
              test_start_date=datetime.datetime(2018, 1, 4),
              relative_error_tolerance=0.05,
          )
  
          assert forecast.forecast_horizon is None
          assert forecast.df_train.shape == (2, 6)
          assert forecast.df_test.shape == (1, 6)
          assert forecast.relative_error_tolerance == 0.05
  
          # evaluation metrics (train_metrics remain the same, test_metrics change)
          enum = EvaluationMetricEnum.Correlation
          assert (
              forecast.train_evaluation[enum.get_metric_name()] == 1.0
          )
          assert (
              forecast.test_evaluation[enum.get_metric_name()] is None
          )
          enum = EvaluationMetricEnum.MeanAbsoluteError
          assert (
              forecast.train_evaluation[enum.get_metric_name()] == 1.0
          )
          assert forecast.test_evaluation[enum.get_metric_name()] == 2.0
          enum = EvaluationMetricEnum.RootMeanSquaredError
          assert forecast.train_evaluation[
              enum.get_metric_name()
          ] == math.sqrt(2)
          assert forecast.test_evaluation[enum.get_metric_name()] == 2.0
          enum = EvaluationMetricEnum.MedianAbsoluteError
          assert (
              forecast.train_evaluation[enum.get_metric_name()] == 1.0
          )
          assert forecast.test_evaluation[enum.get_metric_name()] == 2.0
          enum = EvaluationMetricEnum.MeanAbsolutePercentError
          assert (
              forecast.train_evaluation[enum.get_metric_name()] == 50.0
          )
          assert (
              forecast.test_evaluation[enum.get_metric_name()] == 50.0
          )
          assert (
              forecast.train_evaluation[cst.R2_null_model_score] == -7.0
          )
          assert (
              forecast.test_evaluation[cst.R2_null_model_score] == 0.36
          )
          assert (
              forecast.train_evaluation[cst.FRACTION_OUTSIDE_TOLERANCE]
              == 0.5
          )
          assert (
              forecast.test_evaluation[cst.FRACTION_OUTSIDE_TOLERANCE]
              == 1.0
          )
          # validation metrics
          assert (
              forecast.train_evaluation[cst.PREDICTION_BAND_WIDTH]
              == 250.0
          )
          assert (
              forecast.test_evaluation[cst.PREDICTION_BAND_WIDTH]
              == 75.0
          )
          assert (
              forecast.train_evaluation[cst.PREDICTION_BAND_COVERAGE]
              == 0.5
          )
          assert (
              forecast.test_evaluation[cst.PREDICTION_BAND_COVERAGE]
              == 0.0
          )
          assert (
              forecast.train_evaluation[cst.LOWER_BAND_COVERAGE] == 0.5
          )
          assert (
              forecast.test_evaluation[cst.LOWER_BAND_COVERAGE] == 0.0
          )
          assert (
              forecast.train_evaluation[cst.UPPER_BAND_COVERAGE] == 0.0
          )
          assert (
              forecast.test_evaluation[cst.UPPER_BAND_COVERAGE] == 0.0
          )
          assert forecast.train_evaluation[
              cst.COVERAGE_VS_INTENDED_DIFF
          ] == pytest.approx(-0.45)
          assert forecast.test_evaluation[
              cst.COVERAGE_VS_INTENDED_DIFF
          ] == pytest.approx(-0.95)
  
imports: import datetime
  import math
  import sys
  from functools import partial
  import numpy
  import pandas
  import pytest
  from pandas.testing import assert_frame_equal
  from pandas.testing import assert_series_equal
  from sklearn.pipeline import Pipeline
  from greykite.common import constants
  from greykite.common.evaluation import ElementwiseEvaluationMetricEnum
  from greykite.common.evaluation import EvaluationMetricEnum
  from greykite.common.python_utils import assert_equal
  from greykite.common.testing_utils import gen_sliced_df
  from greykite.framework.input.univariate_time_series import UnivariateTimeSeries
  from greykite.framework.output.univariate_forecast import UnivariateForecast
  from greykite.framework.pipeline.utils import get_forecast
  from greykite.sklearn.estimator.prophet_estimator import ProphetEstimator
  from greykite.sklearn.estimator.silverkite_estimator import SilverkiteEstimator
  from greykite.sklearn.estimator.testing_utils import params_component_breakdowns
label_desc: Use image node_id 4 for calling a global function with example usage: test_univariate_forecast(df) without return types