From d1896569a1d710e433836b69778cb5c8cdbe5475 Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Tue, 24 Sep 2024 15:40:52 -0700 Subject: [PATCH 1/2] Remove custom parameters --- optimas/core/trial.py | 18 ------------------ optimas/gen_functions.py | 3 --- optimas/generators/base.py | 2 -- 3 files changed, 23 deletions(-) diff --git a/optimas/core/trial.py b/optimas/core/trial.py index 6879cb32..5e661a19 100644 --- a/optimas/core/trial.py +++ b/optimas/core/trial.py @@ -17,7 +17,6 @@ class TrialStatus(int, Enum): COMPLETED = 2 FAILED = 3 - class Trial: """Defines a trial to be evaluated. @@ -36,10 +35,6 @@ class Trial: parameter). index : int, optional Index of the trial. - custom_parameters : list of TrialParameter, optional - Additional parameters needed to identify or carry out the trial, and - which will be included in the optimization history. - """ def __init__( @@ -50,7 +45,6 @@ def __init__( parameter_values: Optional[List[float]] = None, evaluations: Optional[List[Evaluation]] = None, index: Optional[int] = None, - custom_parameters: Optional[List[TrialParameter]] = None, ) -> None: # Process inputs. self._varying_parameters = varying_parameters @@ -63,16 +57,9 @@ def __init__( ) evaluations = [] if evaluations is None else evaluations self._index = index - self._custom_parameters = ( - [] if custom_parameters is None else custom_parameters - ) self._ignored = False self._ignored_reason = None - # Add custom parameters as trial attributes. - for param in self._custom_parameters: - setattr(self, param.name, None) - # Create map of evaluations to objectives and analyzed parameters. self._mapped_evaluations = {} for par in self._objectives + self._analyzed_parameters: @@ -139,11 +126,6 @@ def ignored_reason(self) -> str: """Get the reason why the trial is ignored by the generator.""" return self._ignored_reason - @property - def custom_parameters(self) -> List[TrialParameter]: - """Get the list of custom trial parameters.""" - return self._custom_parameters - @property def status(self) -> TrialStatus: """Get current trial status.""" diff --git a/optimas/gen_functions.py b/optimas/gen_functions.py index c3e37eb3..3b08c33f 100644 --- a/optimas/gen_functions.py +++ b/optimas/gen_functions.py @@ -78,9 +78,6 @@ def persistent_generator(H, persis_info, gen_specs, libE_info): if "task" in H_o.dtype.names: H_o["task"][i] = trial.trial_type run_params = run_params[trial.trial_type] - if trial.custom_parameters is not None: - for par in trial.custom_parameters: - H_o[par.save_name][i] = getattr(trial, par.name) H_o["trial_index"][i] = trial.index H_o["num_procs"][i] = run_params["num_procs"] H_o["num_gpus"][i] = run_params["num_gpus"] diff --git a/optimas/generators/base.py b/optimas/generators/base.py index 931a64e1..2a33957a 100644 --- a/optimas/generators/base.py +++ b/optimas/generators/base.py @@ -211,7 +211,6 @@ def ask(self, n_trials: int) -> List[Trial]: varying_parameters=self._varying_parameters, objectives=self._objectives, analyzed_parameters=self._analyzed_parameters, - custom_parameters=self._custom_trial_parameters, ) ) # Ask the generator to fill them. @@ -489,7 +488,6 @@ def _create_trials_from_external_data( ], objectives=self._objectives, analyzed_parameters=self._analyzed_parameters, - custom_parameters=self._custom_trial_parameters, ) for par in self._custom_trial_parameters: setattr(trial, par.name, trial_data[par.save_name][i]) From b8a684de52ccd28671b80585529d79a187733612 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 22:41:41 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- optimas/core/trial.py | 1 + 1 file changed, 1 insertion(+) diff --git a/optimas/core/trial.py b/optimas/core/trial.py index 5e661a19..94d3877f 100644 --- a/optimas/core/trial.py +++ b/optimas/core/trial.py @@ -17,6 +17,7 @@ class TrialStatus(int, Enum): COMPLETED = 2 FAILED = 3 + class Trial: """Defines a trial to be evaluated.