Total Complexity | 3 |
Total Lines | 36 |
Duplicated Lines | 75 % |
Changes | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | # Author: Simon Blanke |
||
2 | # Email: [email protected] |
||
3 | # License: MIT License |
||
4 | |||
5 | |||
6 | from tqdm import tqdm |
||
7 | |||
8 | |||
9 | View Code Duplication | def _process_(optimizer): |
|
|
|||
10 | if "progress_bar" in optimizer.verbosity: |
||
11 | p_bar = tqdm( |
||
12 | position=optimizer.nth_process, |
||
13 | total=optimizer.n_iter, |
||
14 | ascii=" ─", |
||
15 | colour="Yellow", |
||
16 | ) |
||
17 | else: |
||
18 | p_bar = None |
||
19 | |||
20 | optimizer._search(p_bar) |
||
21 | |||
22 | if p_bar: |
||
23 | p_bar.colour = "GREEN" |
||
24 | p_bar.refresh() |
||
25 | p_bar.close() |
||
26 | |||
27 | return { |
||
28 | "nth_process": optimizer.nth_process, |
||
29 | "best_para": optimizer.best_para, |
||
30 | "best_score": optimizer.best_score, |
||
31 | "best_iter": optimizer.best_since_iter, |
||
32 | "eval_times": optimizer.eval_times, |
||
33 | "iter_times": optimizer.iter_times, |
||
34 | "search_data": optimizer.search_data, |
||
35 | "random_seed": optimizer.random_seed, |
||
36 | } |
||
37 |