code: def test_filter_changepoints():
      cp_blocks = [[1, 2, 4, 5], [8], [12, 14]]
      coef = np.array(
          [0, 10, 5, 0, -5, 10, 0, 0, 10, 0, 0, 0, 10, 0, 5]
      )
      min_index_distance = 3
      selected_changepoints = filter_changepoints(
          cp_blocks=cp_blocks,
          coef=coef,
          min_index_distance=min_index_distance,
      )
      assert selected_changepoints == [1, 5, 8, 12]
  
      cp_blocks = [[1, 3, 5, 7, 9]]
      coef = np.array([0, 2, 0, 4, 0, 6, 0, 9, 0, 10])
      min_index_distance = 5
      selected_changepoints = filter_changepoints(
          cp_blocks=cp_blocks,
          coef=coef,
          min_index_distance=min_index_distance,
      )
      assert selected_changepoints == [3, 9]
  
      cp_blocks = [[1, 3, 5, 7, 9]]
      coef = np.array([0, 2, 0, 4, 0, 6, 0, 9, 0, 10])
      min_index_distance = 3
      selected_changepoints = filter_changepoints(
          cp_blocks=cp_blocks,
          coef=coef,
          min_index_distance=min_index_distance,
      )
      assert selected_changepoints == [1, 5, 9]
  
      cp_blocks = [[1, 3, 5, 7, 9]]
      coef = np.array([0, 2, 0, 4, 0, 6, 0, 9, 0, 10])
      min_index_distance = 2
      selected_changepoints = filter_changepoints(
          cp_blocks=cp_blocks,
          coef=coef,
          min_index_distance=min_index_distance,
      )
      assert selected_changepoints == [1, 3, 5, 7, 9]
  
      cp_blocks = [[1, 3, 5, 7, 9]]
      coef = np.array([0, 2, 0, 4, 0, 6, 0, 9, 0, 10])
      min_index_distance = 1
      selected_changepoints = filter_changepoints(
          cp_blocks=cp_blocks,
          coef=coef,
          min_index_distance=min_index_distance,
      )
      assert selected_changepoints == [1, 3, 5, 7, 9]
  
      cp_blocks = [[1, 2, 4, 7, 11, 12], [30, 32, 33], [41, 46], [59]]
      coef = np.array(
          [
              0,
              10,
              -5,
              0,
              8,
              0,
              0,
              -12,
              0,
              0,
              0,
              -1,
              8,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              9,
              0,
              3,
              -6,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              12,
              0,
              0,
              0,
              0,
              -18,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              4,
          ]
      )
      min_index_distance = 2
      selected_changepoints = filter_changepoints(
          cp_blocks=cp_blocks,
          coef=coef,
          min_index_distance=min_index_distance,
      )
      assert selected_changepoints == [1, 4, 7, 12, 30, 33, 41, 46, 59]
  
      cp_blocks = [[1, 2, 4, 7, 11, 12], [30, 32, 33], [41, 46], [59]]
      coef = np.array(
          [
              0,
              10,
              -5,
              0,
              8,
              0,
              0,
              -12,
              0,
              0,
              0,
              -1,
              8,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              9,
              0,
              3,
              -6,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              12,
              0,
              0,
              0,
              0,
              -18,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              4,
          ]
      )
      min_index_distance = 3
      selected_changepoints = filter_changepoints(
          cp_blocks=cp_blocks,
          coef=coef,
          min_index_distance=min_index_distance,
      )
      assert selected_changepoints == [1, 4, 7, 12, 30, 33, 41, 46, 59]
  
      cp_blocks = [[1, 2, 4, 7, 11, 12], [30, 32, 33], [41, 46], [59]]
      coef = np.array(
          [
              0,
              10,
              -5,
              0,
              8,
              0,
              0,
              -12,
              0,
              0,
              0,
              -1,
              8,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              9,
              0,
              3,
              -6,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              12,
              0,
              0,
              0,
              0,
              -18,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              4,
          ]
      )
      min_index_distance = 6
      selected_changepoints = filter_changepoints(
          cp_blocks=cp_blocks,
          coef=coef,
          min_index_distance=min_index_distance,
      )
      assert selected_changepoints == [1, 7, 30, 46, 59]
  
      with pytest.raises(
          ValueError,
          match="`min_index_distance` is the minimum distance between change point"
          "indices to consider them separate, and must be positive.",
      ):
          filter_changepoints(
              cp_blocks=cp_blocks, coef=coef, min_index_distance=0
          )
  
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 12 for calling a global function with example usage: test_filter_changepoints() without return types