code: def test_get_changepoints_dict():
      dl = DataLoader()
      df_pt = dl.load_peyton_manning()
  
      changepoints_dict = {
          "method": "auto",
          "yearly_seasonality_order": 8,
          "resample_freq": "D",
          "trend_estimator": "ridge",
          "adaptive_lasso_initial_estimator": "ridge",
          "regularization_strength": None,
          "actual_changepoint_min_distance": "30D",
          "potential_changepoint_distance": None,
          "potential_changepoint_n": 100,
          "no_changepoint_distance_from_end": None,
          "no_changepoint_proportion_from_end": 0.0,
          "continuous_time_col": "ct1",
      }
      (
          new_changepoints_dict,
          changepoint_detector,
      ) = get_changepoints_dict(
          df=df_pt,
          time_col="ts",
          value_col="y",
          changepoints_dict=changepoints_dict,
      )
      assert new_changepoints_dict["method"] == "custom"
      assert len(new_changepoints_dict["dates"]) > 0
      assert new_changepoints_dict["continuous_time_col"] == "ct1"
      assert changepoint_detector.trend_changepoints is not None
      # tests change point properties
      changepoints_dict = {
          "method": "auto",
          "yearly_seasonality_order": 8,
          "resample_freq": "D",
          "trend_estimator": "ridge",
          "adaptive_lasso_initial_estimator": "ridge",
          "regularization_strength": None,
          "actual_changepoint_min_distance": "100D",
          "potential_changepoint_distance": "50D",
          "potential_changepoint_n": 100,
          "no_changepoint_distance_from_end": None,
          "no_changepoint_proportion_from_end": 0.3,
          "continuous_time_col": "ct1",
          "dates": ["2001-01-01", "2010-01-01"],
      }
      (
          new_changepoints_dict,
          changepoint_detector,
      ) = get_changepoints_dict(
          df=df_pt,
          time_col="ts",
          value_col="y",
          changepoints_dict=changepoints_dict,
      )
      changepoint_dates = new_changepoints_dict["dates"]
      # checks no change points at the end
      assert (
          changepoint_dates[-1] - pd.to_datetime(df_pt["ts"].iloc[0])
      ) / (
          pd.to_datetime(df_pt["ts"].iloc[-1])
          - pd.to_datetime(df_pt["ts"].iloc[0])
      ) <= 0.7
      # checks change point distance is good
      min_cp_dist = min(
          [
              changepoint_dates[i] - changepoint_dates[i - 1]
              for i in range(1, len(changepoint_dates))
          ]
      )
      assert min_cp_dist >= timedelta(days=100)
      assert changepoint_detector.trend_changepoints is not None
      # checks additional custom changepoints are added
      assert (
          pd.to_datetime("2001-01-01") not in changepoint_dates
      )  # out of range
      assert pd.to_datetime("2010-01-01") in changepoint_dates
      # tests for None
      (
          new_changepoints_dict,
          changepoint_detector,
      ) = get_changepoints_dict(
          df=df_pt, time_col="ts", value_col="y", changepoints_dict=None
      )
      assert new_changepoints_dict is None
      assert changepoint_detector is None
      # tests for "custom"
      changepoints_dict = {"method": "custom", "dates": ["2020-01-01"]}
      (
          new_changepoints_dict,
          changepoint_detector,
      ) = get_changepoints_dict(
          df=df_pt,
          time_col="ts",
          value_col="y",
          changepoints_dict=changepoints_dict,
      )
      assert new_changepoints_dict == changepoints_dict
      assert changepoint_detector is None
      # tests for uniform
      changepoints_dict = {"method": "uniform", "n_changepoints": 100}
      (
          new_changepoints_dict,
          changepoint_detector,
      ) = get_changepoints_dict(
          df=df_pt,
          time_col="ts",
          value_col="y",
          changepoints_dict=changepoints_dict,
      )
      assert new_changepoints_dict == changepoints_dict
      assert changepoint_detector is None
      # tests unused keys
      changepoints_dict = {"method": "auto", "unused_key": "value"}
      with pytest.warns(UserWarning, match="The following keys in"):
          get_changepoints_dict(
              df=df_pt,
              time_col="ts",
              value_col="y",
              changepoints_dict=changepoints_dict,
          )
  
imports: from datetime import timedelta
  import numpy
  import pandas
  import pytest
  from pandas.tseries.frequencies import to_offset
  from sklearn.base import RegressorMixin
  from testfixtures import LogCapture
  from greykite.algo.changepoint.adalasso.changepoint_detector import ChangepointDetector
  from greykite.algo.changepoint.adalasso.changepoint_detector import get_changepoints_dict
  from greykite.algo.changepoint.adalasso.changepoint_detector import get_seasonality_changepoints
  from greykite.algo.changepoint.shift_detection.shift_detector import ShiftDetection
  from greykite.common.data_loader import DataLoader
  from greykite.common.logging import LOGGER_NAME
  from greykite.common.testing_utils import generate_df_for_tests
  from greykite.common.testing_utils import generate_df_with_arbitrary_trends_and_shifts
  from greykite.common.testing_utils import generate_test_changepoint_df
label_desc: Use image node_id 7 for calling a global function with example usage: test_get_changepoints_dict() without return types