fileConfig((Path.cwd() / 'config') / 'logging.cfg')
logger = getLogger()
+
class Holidays:
_start = None
- _end = None
+ _end = None
def __init__(self, config_file):
# Collecting holidays features
self._features = [section for section in self._config
- if self._config[section].getboolean('numerical')
- or self._config[section].getboolean('categorical')]
+ if self._config[section].getboolean('binary')
+ or self._config[section].getboolean('categorical')
+ or self._config[section].getboolean('numerical')]
self._dated_features = {}
-
@property
def start(self):
return self._start
def start(self, x):
self._start = x
-
@property
def end(self):
return self._end
def end(self, x):
self._end = x
-
-
def _get_academic_zone(self, name, date):
dict_zones = {
- 'Caen' : ('A', 'B'),
- 'Clermont-Ferrand' : ('A', 'A'),
- 'Grenoble' : ('A', 'A'),
- 'Lyon' : ('A', 'A'),
- 'Montpellier' : ('A', 'C'),
- 'Nancy-Metz' : ('A', 'B'),
- 'Nantes' : ('A', 'B'),
- 'Rennes' : ('A', 'B'),
- 'Toulouse' : ('A', 'C'),
- 'Aix-Marseille' : ('B', 'B'),
- 'Amiens' : ('B', 'B'),
- 'Besançon' : ('B', 'A'),
- 'Dijon' : ('B', 'A'),
- 'Lille' : ('B', 'B'),
- 'Limoges' : ('B', 'A'),
- 'Nice' : ('B', 'B'),
- 'Orléans-Tours' : ('B', 'B'),
- 'Poitiers' : ('B', 'A'),
- 'Reims' : ('B', 'B'),
- 'Rouen ' : ('B', 'B'),
- 'Strasbourg' : ('B', 'B'),
- 'Bordeaux' : ('C', 'A'),
- 'Créteil' : ('C', 'C'),
- 'Paris' : ('C', 'C'),
- 'Versailles' : ('C', 'C')
+ 'Caen': ('A', 'B'),
+ 'Clermont-Ferrand': ('A', 'A'),
+ 'Grenoble': ('A', 'A'),
+ 'Lyon': ('A', 'A'),
+ 'Montpellier': ('A', 'C'),
+ 'Nancy-Metz': ('A', 'B'),
+ 'Nantes': ('A', 'B'),
+ 'Rennes': ('A', 'B'),
+ 'Toulouse': ('A', 'C'),
+ 'Aix-Marseille': ('B', 'B'),
+ 'Amiens': ('B', 'B'),
+ 'Besançon': ('B', 'A'),
+ 'Dijon': ('B', 'A'),
+ 'Lille': ('B', 'B'),
+ 'Limoges': ('B', 'A'),
+ 'Nice': ('B', 'B'),
+ 'Orléans-Tours': ('B', 'B'),
+ 'Poitiers': ('B', 'A'),
+ 'Reims': ('B', 'B'),
+ 'Rouen ': ('B', 'B'),
+ 'Strasbourg': ('B', 'B'),
+ 'Bordeaux': ('C', 'A'),
+ 'Créteil': ('C', 'C'),
+ 'Paris': ('C', 'C'),
+ 'Versailles': ('C', 'C')
}
if date < datetime(2016, 1, 1):
return dict_zones[name][0]
else:
return dict_zones[name][1]
-
@property
def dated_features(self):
if self._dated_features == {}:
logger.info("Adding holidays features")
bankHolidays = tuple(itertools.chain.from_iterable(list(JoursFeries.for_year(k).values())
- for k in range(self.start.year, self.end.year+1)))
- bankHolidaysEve = tuple(u-timedelta(days=1) for u in bankHolidays)
+ for k in range(self.start.year, self.end.year + 1)))
+ bankHolidaysEve = tuple(u - timedelta(days=1) for u in bankHolidays)
name = self._config['ZONE']['name']
date = self._start
Date = datetime.date(date)
Tomorrow = datetime.date(tomorrow)
d = SchoolHolidayDates()
dict_hour = {
- 'bankHolidays' : Date in bankHolidays,
+ '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))
tomorrow = date + timedelta(days=1)
Tomorrow = datetime.date(tomorrow)
dict_hour = {
- 'bankHolidays' : Date in bankHolidays,
+ '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