def test_output_single_series_hfc_lpo_true(self, config):
        """Tests backtest based on historical forecasts generated on a single `series` (or list of one `series`)
        with last_points_only=True"""
        is_univariate, series_as_list, metric = config
        is_multi_metric = len(metric) > 1
        y = ct(value=1.0, length=10)
        hfc = ct(value=2.0, length=10)
        if not is_univariate:
            y = y.stack(y + 1.0)
            hfc = hfc.stack(hfc + 2.0)
        y = y if not series_as_list else [y]
        hfc = hfc if not series_as_list else [hfc]

        model = NaiveDrift()

        # check that input does not work with `last_points_only=False``
        with pytest.raises(ValueError) as err:
            _ = model.backtest(
                series=y,
                historical_forecasts=hfc,
                reduction=None,
                metric=metric,
                last_points_only=False,
            )
        if series_as_list:
            error_msg = "Expected `historical_forecasts` of type `Sequence[Sequence[TimeSeries]]`"
        else:
            error_msg = "Expected `historical_forecasts` of type `Sequence[TimeSeries]`"
        assert str(err.value).startswith(error_msg)

        # number of forecasts do not match number of `series`
        if series_as_list:
            with pytest.raises(ValueError) as err:
                _ = model.backtest(
                    series=y,
                    historical_forecasts=hfc + y,
                    reduction=None,
                    metric=metric,
                    last_points_only=True,
                )
            error_msg = f"expected `historical_forecasts` of type `Sequence[TimeSeries]` with length n={len(y)}."
            assert str(err.value).endswith(error_msg)

        # no reduction
        bt = model.backtest(
            series=y,
            historical_forecasts=hfc,
            reduction=None,
            metric=metric,
            last_points_only=True,
        )
        bt = bt if series_as_list else [bt]
        assert isinstance(bt, list) and len(bt) == 1
        bt = bt[0]
        if not is_multi_metric:
            # inner type expected: 1 float
            assert isinstance(bt, float) and bt == 100.0
        else:
            # inner shape expected: (n metrics = 2,)
            assert isinstance(bt, np.ndarray)
            np.testing.assert_array_almost_equal(bt, np.array([100.0, 100.0]))

        # with reduction
        bt = model.backtest(
            series=y,
            historical_forecasts=hfc,
            reduction=np.mean,
            metric=metric,
            last_points_only=True,
        )
        bt = bt if series_as_list else [bt]
        assert isinstance(bt, list) and len(bt) == 1
        bt = bt[0]
        if not is_multi_metric:
            # inner type expected: 1 float
            assert isinstance(bt, float) and bt == 100.0
        else:
            # inner shape expected: (n metrics = 2,)
            assert isinstance(bt, np.ndarray)
            np.testing.assert_array_almost_equal(bt, np.array([100.0, 100.0]))
Tests backtest based on historical forecasts generated on a single `series` (or list of one `series`)
        with last_points_only=True
darts/tests/models/forecasting/test_backtesting.py