def test_add_datetime_attribute(self):
        """datetime_attributes are 0-indexed (shift is applied when necessary)"""
        seriesA = self.series1.add_datetime_attribute("day")
        assert seriesA.width == self.series1.width + 1
        assert set(
            seriesA.to_dataframe().iloc[:, seriesA.width - 1].values.flatten()
        ) == set(range(0, 10))
        seriesB = self.series3.add_datetime_attribute("day", True)
        assert seriesB.width == self.series3.width + 31
        assert set(
            seriesB.to_dataframe().iloc[:, self.series3.width :].values.flatten()
        ) == {0, 1}
        seriesC = self.series1.add_datetime_attribute("month", True)
        assert seriesC.width == self.series1.width + 12
        seriesD = TimeSeries.from_times_and_values(
            pd.date_range("20130206", "20130430"), range(84)
        )
        seriesD = seriesD.add_datetime_attribute("month", True)
        assert seriesD.width == 13
        assert sum(seriesD.values().flatten()) == sum(range(84)) + 84
        assert sum(seriesD.values()[:, 1 + 3]) == 30
        assert sum(seriesD.values()[:, 1 + 1]) == 23

        # test cyclic
        times_month = pd.date_range("20130101", "20140610")

        seriesE = TimeSeries.from_times_and_values(
            times_month, np.repeat(0.1, len(times_month))
        )
        seriesF = seriesE.add_datetime_attribute("day", cyclic=True)

        values_sin = seriesF.values()[:, 1]
        values_cos = seriesF.values()[:, 2]

        assert np.allclose(np.add(np.square(values_sin), np.square(values_cos)), 1)

        df = seriesF.to_dataframe()
        # first day is equivalent to t=0
        df = df[df.index.day == 1]
        assert np.allclose(df["day_sin"].values, 0, atol=0.03)
        assert np.allclose(df["day_cos"].values, 1, atol=0.03)

        # second day is equivalent to t=1
        df = df[df.index.day == 2]
        assert np.allclose(df["day_sin"].values, 0.2, atol=0.03)
        assert np.allclose(df["day_cos"].values, 0.97, atol=0.03)
datetime_attributes are 0-indexed (shift is applied when necessary)
darts/tests/test_timeseries_multivariate.py