def test_merge_configuration(): """ Test merging two simple configurations works as expected. """ one = {"alpha": [0, 1], BernoulliNB: {"fit_prior": [True, False]}} two = {"alpha": [0, 2], GaussianNB: {"fit_prior": [True, False]}} expected_merged = { "alpha": [0, 1, 2], GaussianNB: { "fit_prior": [True, False] }, BernoulliNB: { "fit_prior": [True, False] }, } actual_merged = merge_configurations(one, two) assert expected_merged == actual_merged
import os from datetime import datetime, timedelta from typing import List, Tuple, Dict import pandas as pd from gama.configuration.classification import clf_config from gama.configuration.parser import pset_from_config, merge_configurations from gama.configuration.regression import reg_config from gama.genetic_programming.components import Individual pset, _ = pset_from_config(merge_configurations(clf_config, reg_config)) class GamaReport: """ Contains information parsed from a search captured by a GAMA analysis log. """ def __init__(self, log_directory: str): """ Parse the logfile or log lines provided. Parameters ---------- log_directory: str The directory with logs: - gama.log - evaluations.log - resources.log """ self._log_directory = os.path.expanduser(log_directory) self.name = os.path.split(log_directory)[-1] self.phases: List[Tuple[str, str, datetime, float]] = [] self._last_tell = 0