docstr: If covariates are given, the index generators should return the covariate series' index.
  If covariates are not given, the index generators should return the target series' index.
docstr_tok: ["If","covariates","are","given",",","the","index","generators","should","return","the","covariate","series","'","index",".","If","covariates","are","not","given",",","the","index","generators","should","return","the","target","series","'","index","."]
code: def helper_test_index_generator_train(
      self, ig: CovariatesIndexGenerator
  ):
      """
      If covariates are given, the index generators should return the covariate series' index.
      If covariates are not given, the index generators should return the target series' index.
      """
      # pd.DatetimeIndex
      # generated index must be equal to input covariate index
      idx, _ = ig.generate_train_idx(
          self.target_time, self.cov_time_train
      )
      assert idx.equals(self.cov_time_train.time_index)
      # generated index must be equal to input covariate index
      idx, _ = ig.generate_train_idx(
          self.target_time, self.cov_time_train_short
      )
      assert idx.equals(self.cov_time_train_short.time_index)
      # generated index must be equal to input target index when no covariates are defined
      idx, _ = ig.generate_train_idx(self.target_time, None)
      assert idx[0] == self.target_time.start_time()
      if isinstance(ig, PastCovariatesIndexGenerator):
          assert (
              idx[-1]
              == self.target_time.end_time()
              - self.output_chunk_length * self.target_time.freq
          )
      else:
          assert idx[-1] == self.target_time.end_time()
  
      # integer index
      # generated index must be equal to input covariate index
      idx, _ = ig.generate_train_idx(
          self.target_int, self.cov_int_train
      )
      assert idx.equals(self.cov_int_train.time_index)
      # generated index must be equal to input covariate index
      idx, _ = ig.generate_train_idx(
          self.target_int, self.cov_int_train_short
      )
      assert idx.equals(self.cov_int_train_short.time_index)
      # generated index must be equal to input target index when no covariates are defined
      idx, _ = ig.generate_train_idx(self.target_int, None)
      assert idx[0] == self.target_int.start_time()
      if isinstance(ig, PastCovariatesIndexGenerator):
          assert (
              idx[-1]
              == self.target_int.end_time()
              - self.output_chunk_length * self.target_int.freq
          )
      else:
          assert idx[-1] == self.target_int.end_time()
  
file_path: darts/darts/tests/dataprocessing/encoders/test_covariate_index_generators.py
imports: import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts.dataprocessing.encoders.encoder_base import CovariatesIndexGenerator, FutureCovariatesIndexGenerator, PastCovariatesIndexGenerator
  from darts.logging import get_logger
  from darts.utils import timeseries_generation
label_desc: Use image node_id 2 for calling the TestCovariatesIndexGenerator obj's underlying member method code with example usage: obj.helper_test_index_generator_train(ig) without return types