def test_FittableAggregator_fit_predict(self, config):
        """Check that consecutive calls to fit() and predict() work as intended"""
        aggregator_cls, cls_kwargs, _ = config
        aggregator = aggregator_cls(**cls_kwargs)

        # name must be of type str
        assert isinstance(
            aggregator.__str__(),
            str,
        )

        # Need to call fit() before calling predict()
        with pytest.raises(ValueError) as err:
            aggregator.predict([self.mts_anomalies1, self.mts_anomalies1])
        assert (
            str(err.value)
            == "The `Aggregator` has not been fitted yet. Call `Aggregator.fit()` first."
        )

        # Check if _fit_called is False before calling fit
        assert not aggregator._fit_called

        aggregator.fit(self.real_anomalies, self.mts_anomalies1)

        # Check if _fit_called is True after calling fit
        assert aggregator._fit_called

        # Check that predict can be called when series is appropriate
        pred = aggregator.predict(self.mts_anomalies1)

        # Check that the aggregated result has only one component
        assert pred.width == 1
Check that consecutive calls to fit() and predict() work as intended
darts/tests/ad/test_aggregators.py