code: def test_build_seasonality_feature_df_with_detection_result():
      df = pd.DataFrame(
          {
              "ts": pd.date_range(
                  start="2020-01-06", end="2020-01-12", freq="D"
              ),
              "y": list(range(7)),
          }
      )
      seasonality_changepoints = {
          "weekly": list(pd.to_datetime(["2020-01-08", "2020-01-11"])),
          "yearly": list(pd.to_datetime(["2020-01-09"])),
      }
      seasonality_components_df = pd.DataFrame(
          {
              "name": ["tow", "conti_year"],
              "period": [7.0, 1.0],
              "order": [1, 2],
              "seas_names": ["weekly", "yearly"],
          }
      )
      # we only assert values equal, since indices may differ
      # with overall block
      seasonality_df = (
          build_seasonality_feature_df_from_detection_result(
              df=df,
              time_col="ts",
              seasonality_changepoints=seasonality_changepoints,
              seasonality_components_df=seasonality_components_df,
              include_original_block=True,
          )
      )
      # date index for changepoints
      week_cp1 = 1  # dates start from the 6th, first weekly cp is the 8th, last index before cp is 1 (from Monday)
      week_cp2 = 4  # dates start from the 6th, second weekly cp is the 11th, last index before cp is 4 (from Monday)
      year_cp1 = 7  # dates start from the 6th, first yearly cp is the 9th, last index before cp is 7 (from the 1st)
      expected_df = pd.DataFrame(
          {
              "sin1_tow_weekly": np.sin(
                  [2 * np.pi * i / 7 for i in range(7)]
              ),
              "cos1_tow_weekly": np.cos(
                  [2 * np.pi * i / 7 for i in range(7)]
              ),
              "sin1_tow_weekly_2020_01_08_00": np.sin(
                  [
                      2 * np.pi * i / 7 if i > week_cp1 else 0
                      for i in range(7)
                  ]
              ),
              "cos1_tow_weekly_2020_01_08_00": np.cos(
                  [
                      2 * np.pi * i / 7 if i > week_cp1 else np.pi / 2
                      for i in range(7)
                  ]
              ),
              "sin1_tow_weekly_2020_01_11_00": np.sin(
                  [
                      2 * np.pi * i / 7 if i > week_cp2 else 0
                      for i in range(7)
                  ]
              ),
              "cos1_tow_weekly_2020_01_11_00": np.cos(
                  [
                      2 * np.pi * i / 7 if i > week_cp2 else np.pi / 2
                      for i in range(7)
                  ]
              ),
              # start date the 6th is 5 days from the 1st, and end date the 12th is 11 days from the 1st
              "sin1_conti_year_yearly": np.sin(
                  [2 * np.pi * i / 366 for i in range(5, 12)]
              ),
              "cos1_conti_year_yearly": np.cos(
                  [2 * np.pi * i / 366 for i in range(5, 12)]
              ),
              "sin2_conti_year_yearly": np.sin(
                  [2 * np.pi * i / 366 * 2 for i in range(5, 12)]
              ),
              "cos2_conti_year_yearly": np.cos(
                  [2 * np.pi * i / 366 * 2 for i in range(5, 12)]
              ),
              "sin1_conti_year_yearly_2020_01_09_00": np.sin(
                  [
                      2 * np.pi * i / 366 if i > year_cp1 else 0
                      for i in range(5, 12)
                  ]
              ),
              "cos1_conti_year_yearly_2020_01_09_00": np.cos(
                  [
                      2 * np.pi * i / 366 if i > year_cp1 else np.pi / 2
                      for i in range(5, 12)
                  ]
              ),
              "sin2_conti_year_yearly_2020_01_09_00": np.sin(
                  [
                      2 * np.pi * i / 366 * 2 if i > year_cp1 else 0
                      for i in range(5, 12)
                  ]
              ),
              "cos2_conti_year_yearly_2020_01_09_00": np.cos(
                  [
                      2 * np.pi * i / 366 * 2
                      if i > year_cp1
                      else np.pi / 2
                      for i in range(5, 12)
                  ]
              ),
          },
          index=df["ts"],
      )
      pd.testing.assert_frame_equal(
          seasonality_df, expected_df, check_names=False
      )
      # without overall block
      seasonality_df = (
          build_seasonality_feature_df_from_detection_result(
              df=df,
              time_col="ts",
              seasonality_changepoints=seasonality_changepoints,
              seasonality_components_df=seasonality_components_df,
              include_original_block=False,
          )
      )
      expected_df = expected_df[
          [
              "sin1_tow_weekly_2020_01_08_00",
              "cos1_tow_weekly_2020_01_08_00",
              "sin1_tow_weekly_2020_01_11_00",
              "cos1_tow_weekly_2020_01_11_00",
              "sin1_conti_year_yearly_2020_01_09_00",
              "cos1_conti_year_yearly_2020_01_09_00",
              "sin2_conti_year_yearly_2020_01_09_00",
              "cos2_conti_year_yearly_2020_01_09_00",
          ]
      ]
      pd.testing.assert_frame_equal(
          seasonality_df, expected_df, check_names=False
      )
      # with weekly only
      with pytest.warns(UserWarning) as record:
          seasonality_df = (
              build_seasonality_feature_df_from_detection_result(
                  df=df,
                  time_col="ts",
                  seasonality_changepoints=seasonality_changepoints,
                  seasonality_components_df=seasonality_components_df,
                  include_original_block=False,
                  include_components=["weekly"],
              )
          )
          assert (
              f"The following seasonality components have detected seasonality changepoints"
              f" but these changepoints are not included in the model,"
              f" because the seasonality component is not included in the model. {['yearly']}"
          ) in record[0].message.args[0]
      expected_df = expected_df[
          [
              "sin1_tow_weekly_2020_01_08_00",
              "cos1_tow_weekly_2020_01_08_00",
              "sin1_tow_weekly_2020_01_11_00",
              "cos1_tow_weekly_2020_01_11_00",
          ]
      ]
      pd.testing.assert_frame_equal(
          seasonality_df, expected_df, check_names=False
      )
  
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 5 for calling a global function with example usage: test_build_seasonality_feature_df_with_detection_result() without return types