| Conditions | 5 |
| Total Lines | 62 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | # Author: Simon Blanke |
||
| 111 | def _search(self, p_bar): |
||
| 112 | self._setup_process() |
||
| 113 | |||
| 114 | gfo_wrapper_model = ObjectiveFunction( |
||
| 115 | experiment=self.experiment, |
||
| 116 | ) |
||
| 117 | gfo_wrapper_model.pass_through = self.pass_through |
||
| 118 | |||
| 119 | memory_warm_start = self.hg_conv.conv_memory_warm_start( |
||
| 120 | self.memory_warm_start |
||
| 121 | ) |
||
| 122 | |||
| 123 | gfo_objective_function = gfo_wrapper_model(self.s_space()) |
||
| 124 | |||
| 125 | self.gfo_optimizer.init_search( |
||
| 126 | gfo_objective_function, |
||
| 127 | self.n_iter, |
||
| 128 | self.max_time, |
||
| 129 | self.max_score, |
||
| 130 | self.early_stopping, |
||
| 131 | self.memory, |
||
| 132 | memory_warm_start, |
||
| 133 | False, |
||
| 134 | ) |
||
| 135 | for nth_iter in range(self.n_iter): |
||
| 136 | if p_bar: |
||
| 137 | p_bar.set_description( |
||
| 138 | "[" |
||
| 139 | + str(self.nth_process) |
||
| 140 | + "] " |
||
| 141 | + str(self.experiment.__class__.__name__) |
||
| 142 | + " (" |
||
| 143 | + self.optimizer_class.name |
||
| 144 | + ")", |
||
| 145 | ) |
||
| 146 | |||
| 147 | self.gfo_optimizer.search_step(nth_iter) |
||
| 148 | if self.gfo_optimizer.stop.check(): |
||
| 149 | break |
||
| 150 | |||
| 151 | if p_bar: |
||
| 152 | p_bar.set_postfix( |
||
| 153 | best_score=str(self.gfo_optimizer.score_best), |
||
| 154 | best_pos=str(self.gfo_optimizer.pos_best), |
||
| 155 | best_iter=str(self.gfo_optimizer.p_bar._best_since_iter), |
||
| 156 | ) |
||
| 157 | |||
| 158 | p_bar.update(1) |
||
| 159 | p_bar.refresh() |
||
| 160 | |||
| 161 | self.gfo_optimizer.finish_search() |
||
| 162 | |||
| 163 | self.convert_results2hyper() |
||
| 164 | |||
| 165 | self._add_result_attributes( |
||
| 166 | self.best_para, |
||
| 167 | self.best_score, |
||
| 168 | self.gfo_optimizer.p_bar._best_since_iter, |
||
| 169 | self.eval_times, |
||
| 170 | self.iter_times, |
||
| 171 | self.search_data, |
||
| 172 | self.gfo_optimizer.random_seed, |
||
| 173 | ) |
||
| 174 |