def test_datetime_attribute_timeseries_leap_years(self):
        """Check that the additional day of leap years is properly handled"""
        days_leap_year = 366
        # 2000 is a leap year, contains 366 days
        index = pd.date_range(
            start=pd.Timestamp("2000-01-01"), end=pd.Timestamp("2000-12-31"), freq="D"
        )
        assert len(index) == days_leap_year
        vals_exp = np.arange(days_leap_year)
        self.helper_routine(index, "day_of_year", vals_exp=vals_exp)
        # full leap year, the encoding is a diagonal matrix
        vals_exp = np.eye(days_leap_year)
        self.helper_routine(index, "day_of_year", vals_exp=vals_exp, one_hot=True)

        # partial leap year, the encoding should still contain 366 columns
        index_partial = index[30:72]
        # remove the missing rows
        vals_exp = vals_exp[30:72]
        # mask the missing dates
        vals_exp[:, :30] = 0
        vals_exp[:, 73:] = 0
        self.helper_routine(
            index_partial, "day_of_year", vals_exp=vals_exp, one_hot=True
        )

        # index containing both a regular year and leap year, for a total of 731 days
        index_long = pd.date_range(
            start=pd.Timestamp("1999-01-01"), end=pd.Timestamp("2000-12-31"), freq="D"
        )
        assert len(index_long) == 731
        # leap year encoding is a diagonal matrix
        leap_year_oh = np.eye(days_leap_year)
        # regular year drops the last day row
        regular_year_oh = np.eye(days_leap_year)
        regular_year_oh = regular_year_oh[:-1]
        vals_exp = np.concatenate([regular_year_oh, leap_year_oh])
        self.helper_routine(index_long, "day_of_year", vals_exp=vals_exp, one_hot=True)
Check that the additional day of leap years is properly handled
darts/tests/utils/test_timeseries_generation.py