code: def test_compute_fitted_components():
      # test trend
      df = pd.DataFrame(
          {
              "changepoint0": [1, 1, 1, 1],
              "changepoint1": [0, 2, 2, 2],
              "sin1_conti_year_yearly_cp0": [
                  np.sin(1),
                  np.sin(2),
                  np.sin(3),
                  np.sin(4),
              ],
              "cos1_conti_year_yearly_cp0": [
                  np.cos(1),
                  np.cos(2),
                  np.cos(3),
                  np.cos(4),
              ],
              "sin1_conti_year_yearly_cp1": [
                  0,
                  0,
                  np.sin(3),
                  np.sin(4),
              ],
              "cos1_conti_year_yearly_cp1": [
                  0,
                  0,
                  np.cos(3),
                  np.cos(4),
              ],
          }
      )
      coef = np.array([1, 2, 3, 4, 5, 6])
      intercept = 1
      trend = compute_fitted_components(
          x=df,
          coef=coef,
          regex="^changepoint",
          include_intercept=True,
          intercept=intercept,
      )
      expected_trend = pd.Series(
          [1 * 1 + 2 * 0 + 1] + [1 * 1 + 2 * 2 + 1] * 3
      )
      assert trend.equals(expected_trend)
      # test yearly seasonality
      df = pd.DataFrame(
          {
              "changepoint0": [1, 1, 1, 1],
              "changepoint1": [0, 2, 2, 2],
              "sin1_conti_year_yearly_cp0": [
                  np.sin(1),
                  np.sin(2),
                  np.sin(3),
                  np.sin(4),
              ],
              "cos1_conti_year_yearly_cp0": [
                  np.cos(1),
                  np.cos(2),
                  np.cos(3),
                  np.cos(4),
              ],
              "sin1_conti_year_yearly_cp1": [
                  0,
                  0,
                  np.sin(3),
                  np.sin(4),
              ],
              "cos1_conti_year_yearly_cp1": [
                  0,
                  0,
                  np.cos(3),
                  np.cos(4),
              ],
          }
      )
      coef = np.array([1, 1, 1, 1, 1, 1])
      seasonality = compute_fitted_components(
          x=df, coef=coef, regex="^.*yearly.*$", include_intercept=False
      )
      expected_seasonality = pd.Series(
          [
              np.sin(1) + np.cos(1),
              np.sin(2) + np.cos(2),
              np.sin(3) + np.cos(3) + np.sin(3) + np.cos(3),
              np.sin(4) + np.cos(4) + np.sin(4) + np.cos(4),
          ]
      )
      assert seasonality.equals(expected_seasonality)
      # tests ValueError
      with pytest.raises(
          ValueError,
          match="``intercept`` must be provided when ``include_intercept`` is True.",
      ):
          compute_fitted_components(
              x=df,
              coef=coef,
              regex="^.*yearly.*$",
              include_intercept=True,
          )
  
imports: from datetime import datetime
  import numpy
  import pandas
  import pytest
  from greykite.algo.changepoint.adalasso.changepoints_utils import adaptive_lasso_cv
  from greykite.algo.changepoint.adalasso.changepoints_utils import build_seasonality_feature_df_from_detection_result
  from greykite.algo.changepoint.adalasso.changepoints_utils import build_seasonality_feature_df_with_changes
  from greykite.algo.changepoint.adalasso.changepoints_utils import build_trend_feature_df_with_changes
  from greykite.algo.changepoint.adalasso.changepoints_utils import check_freq_unit_at_most_day
  from greykite.algo.changepoint.adalasso.changepoints_utils import combine_detected_and_custom_trend_changepoints
  from greykite.algo.changepoint.adalasso.changepoints_utils import compute_fitted_components
  from greykite.algo.changepoint.adalasso.changepoints_utils import compute_min_changepoint_index_distance
  from greykite.algo.changepoint.adalasso.changepoints_utils import estimate_seasonality_with_detected_changepoints
  from greykite.algo.changepoint.adalasso.changepoints_utils import estimate_trend_with_detected_changepoints
  from greykite.algo.changepoint.adalasso.changepoints_utils import filter_changepoints
  from greykite.algo.changepoint.adalasso.changepoints_utils import find_neighbor_changepoints
  from greykite.algo.changepoint.adalasso.changepoints_utils import get_changes_from_beta
  from greykite.algo.changepoint.adalasso.changepoints_utils import get_seasonality_changepoint_df_cols
  from greykite.algo.changepoint.adalasso.changepoints_utils import get_seasonality_changes_from_adaptive_lasso
  from greykite.algo.changepoint.adalasso.changepoints_utils import get_trend_changepoint_dates_from_cols
  from greykite.algo.changepoint.adalasso.changepoints_utils import get_trend_changes_from_adaptive_lasso
  from greykite.algo.changepoint.adalasso.changepoints_utils import get_yearly_seasonality_changepoint_dates_from_freq
  from greykite.algo.changepoint.adalasso.changepoints_utils import plot_change
  from greykite.common.testing_utils import generate_df_for_tests
label_desc: Use image node_id 6 for calling a global function with example usage: test_compute_fitted_components() without return types