Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Jul 28, 2022
1 parent f331135 commit 2b6c168
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dddm/samplers/multi_detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def save_sub_configs(self, force_index=False):
if 'logging' not in c.config:
raise ValueError(f'{c} does not have logging in config ({list(c.config.keys())})')
save_as = os.path.join(f'{save_dir}', f'{c.config["detector"]}_')
with open(save_as + 'config.json', 'w') as file:
with open(f'{save_as}config.json', 'w') as file:
json.dump(convert_dic_to_savable(c.config), file, indent=4)
np.save(save_as + 'config.npy', convert_dic_to_savable(c.config))
np.save(f'{save_as}config.npy', convert_dic_to_savable(c.config))
shutil.copy(c.config['logging'], save_as +
c.config['logging'].split('/')[-1])
self.log.info('save_sub_configs::\tdone_saving')
Expand Down
2 changes: 1 addition & 1 deletion dddm/samplers/ultranest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UltraNestSampler(MultiNestSampler):
"""

def run(self):
warnings.warn(f'Ultranest sampler is not completely implemented yet')
warnings.warn('Ultranest sampler is not completely implemented yet')
self._fix_parameters()
self._print_before_run()

Expand Down
7 changes: 3 additions & 4 deletions tests/test_samplers/test_ultranest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ def test(self, halo_name='shm', max_sigma_off=5, **kwargs, ):
sampler_kwargs=dict(nlive=100, tol=0.9, verbose=1),
fit_parameters=('log_mass', 'log_cross_section',),
)
config = {**base_config, **kwargs}
config = base_config | kwargs
sampler = self.ct.get_sampler_for_detector(**config)

results, _ = sampler.run()

fails = []
for i, (thing, expected, avg, std) in enumerate(
zip(
for thing, expected, avg, std in zip(
base_config.get('fit_parameters'),
[getattr(sampler, f) for f in base_config.get('fit_parameters')],
results['posterior']['mean'],
results['posterior']['stdev']
)):
):
nsigma_off = np.abs(expected - avg) / std
# assert False, dict(thing=thing, expected=expected, avg=avg, nsigma_off=nsigma_off)
message = (f'For {thing}: expected {expected:.2f} yielded '
Expand Down

0 comments on commit 2b6c168

Please sign in to comment.