Skip to content

Commit

Permalink
Make run methods private
Browse files Browse the repository at this point in the history
  • Loading branch information
schmoelder committed Jan 14, 2025
1 parent eaefbd6 commit ae08449
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CADETProcess/optimization/axAdapater.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def _setup_optimization_config(self, objectives, outcome_constraints):
"""
raise NotImplementedError

def run(self, optimization_problem, x0):
def _run(self, optimization_problem, x0):

search_space = self._setup_searchspace(self.optimization_problem)
objectives = self._setup_objectives()
Expand Down
10 changes: 5 additions & 5 deletions CADETProcess/optimization/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ def optimize(
if not flag:
raise ValueError("x0 contains invalid entries.")

log.log_time('Optimization', self.logger.level)(self.run)
log.log_results('Optimization', self.logger.level)(self.run)
log.log_exceptions('Optimization', self.logger.level)(self.run)
log.log_time('Optimization', self.logger.level)(self._run)
log.log_results('Optimization', self.logger.level)(self._run)
log.log_exceptions('Optimization', self.logger.level)(self._run)

backend = plt.get_backend()
plt.switch_backend('agg')

start = time.time()
self.run(self.optimization_problem, x0, *args, **kwargs)
self._run(self.optimization_problem, x0, *args, **kwargs)
time_elapsed = time.time() - start

self.results.time_elapsed = time_elapsed
Expand All @@ -292,7 +292,7 @@ def optimize(
return self.results

@abstractmethod
def run(optimization_problem, x0=None, *args, **kwargs):
def _run(optimization_problem, x0=None, *args, **kwargs):
"""Abstract Method for solving an optimization problem.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion CADETProcess/optimization/pymooAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PymooInterface(OptimizerBase):
'seed', 'pop_size', 'xtol', 'ftol', 'cvtol', 'n_max_gen', 'n_skip'
]

def run(self, optimization_problem: OptimizationProblem, x0=None):
def _run(self, optimization_problem: OptimizationProblem, x0=None):
"""Solve optimization problem using functional pymoo implementation.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion CADETProcess/optimization/scipyAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SciPyInterface(OptimizerBase):
tol = UnsignedFloat()
jac = Switch(valid=['2-point', '3-point', 'cs'], default='2-point')

def run(self, optimization_problem: OptimizationProblem, x0=None):
def _run(self, optimization_problem: OptimizationProblem, x0=None):
"""Solve the optimization problem using any of the scipy methods.
Returns
Expand Down
2 changes: 1 addition & 1 deletion CADETProcess/simulator/cadetAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def get_tempfile_name(self):


@locks_process
def run(self, process, cadet=None, file_path=None):
def _run(self, process, cadet=None, file_path=None):
"""Interface to the solver run function.
The configuration is extracted from the process object and then saved
Expand Down
6 changes: 3 additions & 3 deletions CADETProcess/simulator/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def simulate_n_cycles(
if previous_results is not None:
self.set_state_from_results(process, previous_results)

return self.run(process, **kwargs)
return self._run(process, **kwargs)

self.n_cycles = n_cyc_orig

Expand Down Expand Up @@ -362,7 +362,7 @@ def simulate_to_stationarity(
if results is not None:
self.set_state_from_results(process, results)

new_results = self.run(process, **kwargs)
new_results = self._run(process, **kwargs)

if results is None:
results = new_results
Expand Down Expand Up @@ -414,7 +414,7 @@ def set_state_from_results(self, process, results):
return process

@abstractmethod
def run(process, **kwargs):
def _run(process, **kwargs):
"""Abstract method for running a simulation.
Parameters
Expand Down

0 comments on commit ae08449

Please sign in to comment.