Skip to content

Commit

Permalink
Rewrote trials unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-chevalier committed Oct 15, 2021
1 parent 1a9d203 commit bf0f14d
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 247 deletions.
2 changes: 1 addition & 1 deletion examples/parallel/plot_streaming_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
def eval_run_time(pipeline: BasePipeline):
pipeline.setup()
a = time.time()
output = pipeline.transform(list(range(200)))
output = pipeline.transform(list(range(100)))
b = time.time()
seconds = b - a
return seconds, output
Expand Down
11 changes: 6 additions & 5 deletions neuraxle/metaopt/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ def __init__(
self.start_time: datetime.datetime = start_time
self.end_time: datetime.datetime = end_time

if logger is None and self.cache_folder is not None:
logger = self._initialize_logger_with_file()
if logger is None:
if self.cache_folder is not None:
logger = self._initialize_logger_with_file()
else:
logger = logging.getLogger()
self.logger: Logger = logger

def save_trial(self) -> 'Trial':
Expand Down Expand Up @@ -732,11 +735,9 @@ def get_best_trial(self) -> Trial:
if len(self) == 0:
raise Exception('Could not get best trial because there were no successful trial.')

higher_score_is_better = self.trials[-1].is_higher_score_better()

for trial in self.trials:
trial_score = trial.get_validation_score()
if best_score is None or higher_score_is_better == (trial_score > best_score):
if best_score is None or self.trials[-1].is_higher_score_better() == (trial_score > best_score):
best_score = trial_score
best_trial = trial

Expand Down
Loading

0 comments on commit bf0f14d

Please sign in to comment.