def test_detect_return_type(self, detector_config, series):
        """Check that detect() behave as expected"""
        detector_cls, detector_kwargs = detector_config
        ts_train, ts_test = series
        detector = detector_cls(**detector_kwargs)
        if isinstance(detector, FittableDetector):
            detector.fit(ts_train)

        # Check if return type is TimeSeries when input is a single series
        assert isinstance(detector.detect(ts_test), TimeSeries)
        # Check if return type is Sequence when input is a Sequence of series
        assert isinstance(detector.detect([ts_test]), Sequence)

        # Input cannot be probabilistic
        with pytest.raises(ValueError):
            detector.detect(self.probabilistic)
Check that detect() behave as expected
darts/tests/ad/test_detectors.py