docstr: Check that values are properly extracted when the beginning of the series is not aligned with the low
  frequency anchor value (day of the week).
docstr_tok: ["Check","that","values","are","properly","extracted","when","the","beginning","of","the","series","is","not","aligned","with","the","low","frequency","anchor","value","(","day","of","the","week",")","."]
code: def test_shifted_low_freq_anchor(self):
      """
      Check that values are properly extracted when the beginning of the series is not aligned with the low
      frequency anchor value (day of the week).
      """
      ts = linear_timeseries(
          start=pd.Timestamp("2000-01-01"),
          freq="D",
          start_value=1,
          end_value=22,
          length=22,
      )
      assert ts.time_index[2].day_name() == "Monday"
  
      midas_mon = MIDAS(low_freq="W-MON", strip=False)
      ts_monday_anchor = midas_mon.fit_transform(ts)
      # the resampled series start at the previous anchor point (incomplete)
      assert ts_monday_anchor.time_index[0] == pd.Timestamp(
          "2000-01-03"
      )
      assert ts_monday_anchor.freq == "W-MON"
      assert len(ts_monday_anchor) == 4
      # incomplete low frequency period
      assert (
          ts_monday_anchor[0].values().flatten()[-3:]
          == ts[:3].values().flatten()
      ).all()
      # complete low frequency period
      assert (
          ts_monday_anchor[1].values().flatten()
          == ts[3:10].values().flatten()
      ).all()
  
      # reverse transform
      ts_inv_monday_anchor = midas_mon.inverse_transform(
          ts_monday_anchor
      )
      np.testing.assert_array_almost_equal(
          ts.values(), ts_inv_monday_anchor.values()
      )
      assert ts.time_index.equals(ts_inv_monday_anchor.time_index)
  
      # with strip, it skips first and last week
      midas_mon = MIDAS(low_freq="W-MON", strip=True)
      ts_monday_anchor = midas_mon.fit_transform(ts)
      assert ts_monday_anchor.time_index[0] == pd.Timestamp(
          "2000-01-10"
      )
      assert ts_monday_anchor.freq == "W-MON"
      assert len(ts_monday_anchor) == 2
      # first complete low frequency period
      assert (
          ts_monday_anchor[0].values().flatten()
          == ts[3:10].values().flatten()
      ).all()
  
imports: import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts.dataprocessing.transformers import MIDAS
  from darts.models import LinearRegressionModel
  from darts.utils.timeseries_generation import generate_index, linear_timeseries
label_desc: Use image node_id 16 for calling the TestMIDAS obj's underlying member method code with example usage: obj.test_shifted_low_freq_anchor() without return types