X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/predictops.git/blobdiff_plain/2c5695839a5064f584ffeaba557020ab3270b7b9..90e69cb2125d4bae76a27b9c38defb4f70bf2ca6:/predictops/source/ephemeris.py diff --git a/predictops/source/ephemeris.py b/predictops/source/ephemeris.py index d0e4ca0..e1c07ec 100644 --- a/predictops/source/ephemeris.py +++ b/predictops/source/ephemeris.py @@ -1,12 +1,14 @@ from configparser import ConfigParser -from csv import DictReader from datetime import datetime, timedelta +from logging import getLogger +from logging.config import fileConfig from pathlib import Path import time import calendar -CSV_FILE = Path.cwd() / 'config' / 'features' / 'ephemeris_features.csv' +fileConfig((Path.cwd() / 'config') / 'logging.cfg') +logger = getLogger() class Ephemeris: @@ -15,17 +17,13 @@ class Ephemeris: def __init__(self, config_file): - # Check for the integrity of feature names - super(Source, self).__init__() - self._config = ConfigParser() self._config.read(config_file) # Collecting ephemeris features - with open(CSV_FILE, "r") as f: - reader = DictReader(f, delimiter=',') - self._features = [row['name'] for row in reader - if self._config['FEATURES'].getboolean(row['name'])] + self._features = [section for section in self._config + if self._config[section].getboolean('numerical') + or self._config[section].getboolean('categorical')] self._dated_features = {} @@ -48,10 +46,10 @@ class Ephemeris: self._end = x - @property def dated_features(self): if self._dated_features == {}: + logger.info("Adding ephemeris features") date = self._start while date <= self._end: dict_hour = {}