docstr: Tests that `Diff` class can 'undifference' data that extends beyond
   what was used to fit it (e.g. like when undifferencing a forecast of
   a differenced timeseries, so as to yield a forecast of the undifferenced
   time series)
docstr_tok: ["Tests","that","`","Diff","`","class","can","'undifference","'","data","that","extends","beyond","what","was","used","to","fit","it","(","e.g",".","like","when","undifferencing","a","forecast","of","a","differenced","timeseries",",","so","as","to","yield","a","forecast","of","the","undifferenced","time","series",")"]
code: def test_diff_inverse_transform_beyond_fit_data(self):
      """
      Tests that `Diff` class can 'undifference' data that extends beyond
       what was used to fit it (e.g. like when undifferencing a forecast of
       a differenced timeseries, so as to yield a forecast of the undifferenced
       time series)
      """
  
      # (`lag`, `dropna`) pairs:
      test_cases = [
          (1, True),
          (1, False),
          ([1, 2, 3, 2, 1], True),
          ([1, 2, 3, 2, 1], False),
      ]
  
      # Artifically truncate series:
      short_sine = self.sine_series.copy().drop_after(10)
      for lags, dropna in test_cases:
          # Fit Diff to truncated series:
          diff = Diff(lags=lags, dropna=dropna)
          diff.fit(short_sine)
          # Difference entire time series:
          to_undiff = self.sine_series.copy()
          if not isinstance(lags, Sequence):
              lags = (lags,)
          for lag in lags:
              to_undiff = to_undiff.diff(
                  n=1, periods=lag, dropna=dropna
              )
          # Should be able to undifference entire series even though only fitted
          # to truncated series:
          self.assert_series_equal(
              series1=self.sine_series,
              series2=diff.inverse_transform(to_undiff),
              equal_nan=(not dropna),
          )
  
imports: from copy import deepcopy
  from typing import Optional, Sequence
  import numpy
  import pandas
  import pytest
  from darts.dataprocessing.transformers import Diff
  from darts.timeseries import TimeSeries
  from darts.timeseries import concatenate
  from darts.utils.timeseries_generation import linear_timeseries, sine_timeseries
label_desc: Use image node_id 3 for calling the TestDiff obj's underlying member method code with example usage: obj.test_diff_inverse_transform_beyond_fit_data() without return types