class_docstr: Tests `get_shared_times` function defined in `darts.utils.data.tabularization`.
class_docstr_tok: ["Tests","`","get_shared_times","`","function","defined","in","`","darts.utils.data.tabularization","`","."]
docstr: Tests that `get_shared_times` correctly handles range time
  index series that are of different frequencies.
docstr_tok: ["Tests","that","`","get_shared_times","`","correctly","handles","range","time","index","series","that","are","of","different","frequencies","."]
code: def test_shared_times_unequal_freq_datetime_idx(self):
      """
      Tests that `get_shared_times` correctly handles range time
      index series that are of different frequencies.
      """
      # `series_1` begins before `series_2` does and ends
      # before `series_2` does, and `series_2` begins before
      # `series_3` does and ends before `series_3` does. Each
      # series is of a different frequency:
      series_1 = linear_timeseries(
          start=pd.Timestamp("1/1/2000"),
          end=pd.Timestamp("1/11/2000"),
          freq="2d",
      )
      series_2 = linear_timeseries(
          start=pd.Timestamp("1/3/2000"),
          end=pd.Timestamp("1/13/2000"),
          freq="2d",
      )
      series_3 = linear_timeseries(
          start=pd.Timestamp("1/5/2000"),
          end=pd.Timestamp("1/15/2000"),
          freq="2d",
      )
  
      # Intersection of a single time index is just the original time index:
      assert series_1.time_index.equals(get_shared_times(series_1))
      assert series_2.time_index.equals(get_shared_times(series_2))
      assert series_3.time_index.equals(get_shared_times(series_3))
  
      # Intersection of two time indices begins at start time of later series
      # and stops at end time of earlier series. The frequency of the intersection
      # is the lowest common multiple between the frequencies of the two series:
  
      # `series_1` is before `series_2`:
      freq_12 = f"{lcm(series_1.freq.n, series_2.freq.n)}d"
      expected_12 = linear_timeseries(
          start=series_2.start_time(),
          end=series_1.end_time(),
          freq=freq_12,
      )
      # `linear_timeseries` may have added point beyond specified `end`;
      # remove this point if present:
      if expected_12.time_index[-1] > series_1.end_time():
          expected_12 = expected_12.drop_after(
              expected_12.time_index[-1]
          )
      assert expected_12.time_index.equals(
          get_shared_times(series_1, series_2)
      )
      # `series_2` is before `series_3`:
      freq_23 = f"{lcm(series_2.freq.n, series_3.freq.n)}d"
      expected_23 = linear_timeseries(
          start=series_3.start_time(),
          end=series_2.end_time(),
          freq=freq_23,
      )
      # `linear_timeseries` may have added point beyond specified `end`;
      # remove this point if present:
      if expected_23.time_index[-1] > series_2.end_time():
          expected_23 = expected_23.drop_after(
              expected_23.time_index[-1]
          )
      assert expected_23.time_index.equals(
          get_shared_times(series_2, series_3)
      )
      # `series_1` is before `series_3`:
      freq_13 = f"{lcm(series_1.freq.n, series_3.freq.n)}d"
      expected_13 = linear_timeseries(
          start=series_3.start_time(),
          end=series_1.end_time(),
          freq=freq_13,
      )
      # `linear_timeseries` may have added point beyond specified `end`;
      # remove this point if present:
      if expected_13.time_index[-1] > series_1.end_time():
          expected_13 = expected_13.drop_after(
              expected_13.time_index[-1]
          )
      assert expected_13.time_index.equals(
          get_shared_times(series_1, series_3)
      )
  
      # Intersection of all three time series should begin at start of series_3 (i.e.
      # the last series to begin) and end at the end of series_1 (i.e. the first series
      # to end). The frequency of the intersection should be the lowest common multiple
      # shared by all three frequencies:
      freq_123 = (
          f"{lcm(series_1.freq.n, series_2.freq.n, series_3.freq.n)}d"
      )
      expected_123 = linear_timeseries(
          start=series_3.start_time(),
          end=series_1.end_time(),
          freq=freq_123,
      )
      if expected_123.time_index[-1] > series_1.end_time():
          expected_123 = expected_123.drop_after(
              expected_123.time_index[-1]
          )
      assert expected_123.time_index.equals(
          get_shared_times(series_1, series_2, series_3)
      )
  
imports: from math import gcd
  import pandas
  import pytest
  from darts.utils.data.tabularization import get_shared_times
  from darts.utils.timeseries_generation import linear_timeseries
label_desc: Use image node_id 4 for calling the TestGetSharedTimes obj's underlying member method code with example usage: obj.test_shared_times_unequal_freq_datetime_idx() without return types