|
9 | 9 | import re |
10 | 10 | import shutil |
11 | 11 | import sys |
12 | | -import pandas as pd |
13 | 12 |
|
| 13 | +import pandas as pd |
14 | 14 | from ruamel.yaml import error |
15 | 15 |
|
16 | 16 | from reportengine import colors |
17 | 17 | from reportengine.namespaces import NSList |
| 18 | +from validphys.api import API |
18 | 19 | from validphys.app import App |
19 | 20 | from validphys.config import Config, ConfigError, Environment, EnvironmentError_ |
20 | 21 | from validphys.core import FitSpec |
21 | | -from validphys.utils import yaml_safe |
22 | | -from validphys.loader import FallbackLoader, HyperscanNotFound |
23 | | -from validphys.api import API |
24 | 22 | from validphys.hyperoptplot import generate_dictionary |
| 23 | +from validphys.loader import FallbackLoader, HyperscanNotFound |
| 24 | +from validphys.utils import yaml_safe |
25 | 25 |
|
26 | 26 | loader = FallbackLoader() |
27 | 27 |
|
@@ -240,38 +240,42 @@ def produce_hyperscanner(self, parameters, hyperscan_config=None, hyperopt=None) |
240 | 240 | "db_path": db_path, |
241 | 241 | } |
242 | 242 | return HyperScanner(parameters, hyperscan_config, **extra_args) |
243 | | - |
| 243 | + |
244 | 244 | def parse_trial_specs(self, trial_specs): |
245 | 245 | return trial_specs |
246 | | - |
| 246 | + |
247 | 247 | def produce_trials(self, trial_specs={}): |
248 | | - """Read the input hyperscan and produce a dictionary containing |
| 248 | + """Read the input hyperscan and produce a dictionary containing |
249 | 249 | the settings of the best trials""" |
250 | | - |
| 250 | + |
251 | 251 | if not trial_specs: |
252 | 252 | return {} |
253 | 253 | else: |
254 | 254 | try: |
255 | 255 | hyperscan = loader.check_hyperscan(trial_specs['hyperscan']) |
256 | 256 | except HyperscanNotFound as e: |
257 | 257 | log.warning(e) |
258 | | - dict_trials = generate_dictionary(hyperscan.tries_files[1].parent,"average") |
| 258 | + dict_trials = generate_dictionary(hyperscan.tries_files[1].parent, "average") |
259 | 259 | hyperopt_dataframe = pd.DataFrame(dict_trials) |
260 | 260 | n_termalization = trial_specs['thermalization'] |
261 | 261 | n_best = trial_specs['number_of_trials'] |
262 | | - best = hyperopt_dataframe[n_termalization:].sort_values('loss')[:n_best].to_dict(orient='list') |
| 262 | + best = ( |
| 263 | + hyperopt_dataframe[n_termalization:] |
| 264 | + .sort_values('loss')[:n_best] |
| 265 | + .to_dict(orient='list') |
| 266 | + ) |
263 | 267 | best['number_of_trials'] = n_best |
264 | 268 | return best |
265 | | - |
| 269 | + |
266 | 270 |
|
267 | 271 | class N3FitApp(App): |
268 | 272 | """The class which parsers and performs the fit""" |
269 | 273 |
|
270 | 274 | environment_class = N3FitEnvironment |
271 | 275 | config_class = N3FitConfig |
272 | 276 |
|
273 | | - def __init__(self): |
274 | | - super().__init__(name="n3fit", providers=N3FIT_PROVIDERS) |
| 277 | + def __init__(self, name="n3fit", providers=N3FIT_PROVIDERS): |
| 278 | + super().__init__(name=name, providers=providers) |
275 | 279 |
|
276 | 280 | @property |
277 | 281 | def argparser(self): |
|
0 commit comments