def test_conformal_historical_start_cal_length(self, config):
        """Tests naive conformal model historical forecasts without `cal_stride`."""
        (
            last_points_only,
            cal_length,
            use_start,
            start_format,
            use_int_idx,
            use_multi_series,
            ocs,
        ) = config
        q = [0.1, 0.5, 0.9]
        pred_lklp = {"num_samples": 1, "predict_likelihood_parameters": True}
        # compute minimum series length to generate n forecasts
        icl = 3
        ocl = 5
        horizon = 5
        horizon_ocs = horizon + ocs
        add_cal_length = cal_length - 1 if cal_length is not None else 0
        add_start = 2 * int(use_start)
        min_len_val_series = icl + 2 * horizon_ocs + add_cal_length + add_start
        n_forecasts = 3
        # get train and val series of that length
        series = self.ts_pass_val[: min_len_val_series + n_forecasts - 1]

        if use_int_idx:
            series = TimeSeries.from_values(
                values=series.all_values(),
                columns=series.columns,
            )

        # first train the ForecastingModel
        forecasting_model = LinearRegressionModel(
            lags=icl,
            output_chunk_length=ocl,
            output_chunk_shift=ocs,
        )
        forecasting_model.fit(series)

        # optionally compute the start as a positional index
        start_position = icl + horizon_ocs + add_cal_length + add_start
        start = None
        if use_start:
            if start_format == "value":
                start = series.time_index[start_position]
            else:
                start = start_position

        # add an offset and rename columns in second series to make sure that conformal hist fc works as expected
        if use_multi_series:
            series = [
                series,
                (series + 10).shift(1).with_columns_renamed(series.columns, "test_col"),
            ]

        # compute conformal historical forecasts (skips some of the first forecasts to get minimum required cal set)
        model = ConformalNaiveModel(
            forecasting_model, quantiles=q, cal_length=cal_length
        )
        hist_fct = model.historical_forecasts(
            series=series,
            retrain=False,
            start=start,
            start_format=start_format,
            last_points_only=last_points_only,
            forecast_horizon=horizon,
            overlap_end=False,
            **pred_lklp,
        )

        if not isinstance(series, list):
            series = [series]
            hist_fct = [hist_fct]

        for idx, (
            series_,
            hfc,
        ) in enumerate(zip(series, hist_fct)):
            if not isinstance(hfc, list):
                hfc = [hfc]

            # multi series: second series is shifted by one time step (+/- idx);
            # start_format = "value" requires a shift
            add_start_series_2 = idx * int(use_start) * int(start_format == "value")

            n_preds_without_overlap = (
                len(series_)
                - icl  # input for first prediction
                - horizon_ocs  # skip first forecasts to avoid look-ahead bias
                - horizon_ocs  # cannot compute with `overlap_end=False`
                + 1  # minimum one forecast
                - add_cal_length  # skip based on train length
                - add_start  # skip based on start
                + add_start_series_2  # skip based on start if second series
            )
            if not last_points_only:
                n_pred_series_expected = n_preds_without_overlap
                n_pred_points_expected = horizon
                # seconds series is shifted by one time step (- idx)
                first_ts_expected = series_.time_index[
                    start_position - add_start_series_2 + ocs
                ]
                last_ts_expected = series_.end_time()
            else:
                n_pred_series_expected = 1
                n_pred_points_expected = n_preds_without_overlap
                # seconds series is shifted by one time step (- idx)
                first_ts_expected = (
                    series_.time_index[start_position - add_start_series_2]
                    + (horizon_ocs - 1) * series_.freq
                )
                last_ts_expected = series_.end_time()

            cols_excpected = likelihood_component_names(
                series_.columns, quantile_names(q)
            )
            # check historical forecasts dimensions
            assert len(hfc) == n_pred_series_expected
            # check hist fc start
            assert hfc[0].start_time() == first_ts_expected
            # check hist fc end
            assert hfc[-1].end_time() == last_ts_expected
            for hfc_ in hfc:
                assert hfc_.columns.tolist() == cols_excpected
                assert len(hfc_) == n_pred_points_expected
Tests naive conformal model historical forecasts without `cal_stride`.
darts/tests/utils/historical_forecasts/test_historical_forecasts.py