]> AND Private Git Repository - predictops.git/blobdiff - predictops/source/holidays.py
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
lightgbm is now working
[predictops.git] / predictops / source / holidays.py
index 1a536fe102e52b930314105006b8f3950fbd9f64..6893db03ef5ef7eb804d3f1d9ec391cf18a2dcaf 100644 (file)
@@ -3,6 +3,7 @@ from datetime import datetime, timedelta
 from jours_feries_france.compute import JoursFeries
 from logging import getLogger
 from logging.config import fileConfig
 from jours_feries_france.compute import JoursFeries
 from logging import getLogger
 from logging.config import fileConfig
+from pathlib import Path
 from vacances_scolaires_france import SchoolHolidayDates
 
 import itertools
 from vacances_scolaires_france import SchoolHolidayDates
 
 import itertools
@@ -90,17 +91,28 @@ class Holidays:
             bankHolidaysEve = tuple(u-timedelta(days=1) for u in bankHolidays)
             name = self._config['ZONE']['name']
             date = self._start
             bankHolidaysEve = tuple(u-timedelta(days=1) for u in bankHolidays)
             name = self._config['ZONE']['name']
             date = self._start
+            Date = datetime.date(date)
+            tomorrow = date + timedelta(days=1)
+            Tomorrow = datetime.date(tomorrow)
             d = SchoolHolidayDates()
             d = SchoolHolidayDates()
+            dict_hour = {
+                'bankHolidays' : Date in bankHolidays,
+                'bankHolidaysEve': Date in bankHolidaysEve,
+                'holidays': d.is_holiday_for_zone(Date, self._get_academic_zone(name, date)),
+                'holidaysEve': d.is_holiday_for_zone(Tomorrow, self._get_academic_zone(name, tomorrow))
+            }
             while date <= self._end:
             while date <= self._end:
-                Date = datetime.date(date)
-                tomorrow = date + timedelta(days=1)
-                Tomorrow = datetime.date(tomorrow)
-                dict_hour = {
-                    'bankHolidays' : Date in bankHolidays,
-                    'bankHolidaysEve': Date in bankHolidaysEve,
-                    'holidays': d.is_holiday_for_zone(Date, self._get_academic_zone(name, date)),
-                    'holidaysEve': d.is_holiday_for_zone(Tomorrow, self._get_academic_zone(name, tomorrow))
-                }
                 self._dated_features[date] = dict_hour
                 self._dated_features[date] = dict_hour
+                current = date
                 date += timedelta(hours=1)
                 date += timedelta(hours=1)
+                if date.day != current.day:
+                    Date = datetime.date(date)
+                    tomorrow = date + timedelta(days=1)
+                    Tomorrow = datetime.date(tomorrow)
+                    dict_hour = {
+                        'bankHolidays' : Date in bankHolidays,
+                        'bankHolidaysEve': Date in bankHolidaysEve,
+                        'holidays': d.is_holiday_for_zone(Date, self._get_academic_zone(name, date)),
+                        'holidaysEve': d.is_holiday_for_zone(Tomorrow, self._get_academic_zone(name, tomorrow))
+                    }
         return self._dated_features
\ No newline at end of file
         return self._dated_features
\ No newline at end of file