code: def test_extract(self):
      # test default (naive) method
      calc_trend, _ = extract_trend_and_seasonality(self.ts, freq=6)
      diff = self.trend - calc_trend
      assert np.isclose(np.mean(diff.values() ** 2), 0.0)
  
      # test default (naive) method additive
      calc_trend, _ = extract_trend_and_seasonality(
          self.ts, freq=6, model=ModelMode.ADDITIVE
      )
      diff = self.trend - calc_trend
      assert np.isclose(np.mean(diff.values() ** 2), 0.0)
  
      # test STL method
      calc_trend, _ = extract_trend_and_seasonality(
          self.ts, freq=6, method="STL", model=ModelMode.ADDITIVE
      )
      diff = self.trend - calc_trend
      assert np.isclose(np.mean(diff.values() ** 2), 0.0)
  
      # test MSTL method
      calc_trend, calc_seasonality = extract_trend_and_seasonality(
          self.ts, freq=[3, 6], method="MSTL", model=ModelMode.ADDITIVE
      )
      assert len(calc_seasonality.components) == 2
      diff = self.trend - calc_trend
      # relaxed tolerance for MSTL since it will have a larger error from the
      # extrapolation of the trend, it is still a small number but is more
      # than STL or naive trend extraction
      assert np.isclose(np.mean(diff.values() ** 2), 0.0, atol=1e-5)
  
      # test MSTL method with single freq
      calc_trend, calc_seasonality = extract_trend_and_seasonality(
          self.ts, freq=6, method="MSTL", model=ModelMode.ADDITIVE
      )
      assert len(calc_seasonality.components) == 1
      diff = self.trend - calc_trend
      assert np.isclose(np.mean(diff.values() ** 2), 0.0, atol=1e-5)
  
      # make sure non MSTL methods fail with multiple freqs
      with pytest.raises(ValueError):
          calc_trend, calc_seasonality = extract_trend_and_seasonality(
              self.ts,
              freq=[1, 4, 6],
              method="STL",
              model=ModelMode.ADDITIVE,
          )
  
      # check if error is raised when using multiplicative model
      with pytest.raises(ValueError):
          calc_trend, _ = extract_trend_and_seasonality(
              self.ts,
              freq=6,
              method="STL",
              model=ModelMode.MULTIPLICATIVE,
          )
  
      with pytest.raises(ValueError):
          calc_trend, _ = extract_trend_and_seasonality(
              self.ts,
              freq=[3, 6],
              method="MSTL",
              model=ModelMode.MULTIPLICATIVE,
          )
  
file_path: darts/darts/tests/utils/test_statistics.py
imports: import matplotlib.pyplot
  import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts.datasets import AirPassengersDataset
  from darts.utils.statistics import check_seasonality, extract_trend_and_seasonality, granger_causality_tests, plot_pacf, plot_residuals_analysis, remove_seasonality, remove_trend, stationarity_test_adf, stationarity_test_kpss, stationarity_tests
  from darts.utils.timeseries_generation import constant_timeseries, gaussian_timeseries, linear_timeseries
  from darts.utils.utils import ModelMode, SeasonalityMode
label_desc: Use image node_id 1 for calling the TestSeasonalDecompose obj's underlying member method code with example usage: obj.test_extract() without return types