Skip to content

Commit

Permalink
ex16 - joining some lines
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoleski committed Jan 2, 2025
1 parent b8a6085 commit 328d4f8
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions examples/example_16/ulens_model_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
raise ImportError('\nYou have to install MulensModel first!\n')


__version__ = '0.42.0'
__version__ = '0.42.1'


class UlensModelFit(object):
Expand Down Expand Up @@ -1109,13 +1109,10 @@ def _parse_other_output_parameters_yaml_output(self, values):
try:
self._yaml_results_file = open(value, 'w')
except Exception:
raise ValueError('Error while opening output '
'YAML file ' + str(value))
self._yaml_kwargs = {'file': self._yaml_results_file,
'flush': True}
raise ValueError('Error while opening output YAML file ' + str(value))
self._yaml_kwargs = {'file': self._yaml_results_file, 'flush': True}
else:
raise KeyError("Unrecognized key: " + str(key) +
"\nExpected keys: 'file name'.")
raise KeyError("Unrecognized key: " + str(key) + "\nExpected keys: 'file name'.")

def _parse_other_output_parameters_residuals(self, values):
"""
Expand Down Expand Up @@ -2897,17 +2894,15 @@ def _parse_results_EMCEE(self):
blob_samples = self._get_fluxes_to_print_EMCEE()
self._print_results(blob_samples, names='fluxes')
if self._yaml_results:
print("Fitted fluxes: # (source and blending)",
**self._yaml_kwargs)
print("Fitted fluxes: # (source and blending)", **self._yaml_kwargs)
self._print_yaml_results(blob_samples, names='fluxes')

self._print_best_model()
if self._yaml_results:
self._print_yaml_best_model()

if self._shift_t_0 and self._yaml_results:
print("Plots shift_t_0 : {:}".format(self._shift_t_0_val),
**self._yaml_kwargs)
print("Plots shift_t_0 : {:}".format(self._shift_t_0_val), **self._yaml_kwargs)

def _extract_posterior_samples_EMCEE(self):
"""
Expand Down Expand Up @@ -2998,8 +2993,7 @@ def _print_yaml_results(self, data, names="parameters", mode=None):
raise ValueError("internal bug")

print("# [median, sigma+, sigma-]", **self._yaml_kwargs)
print(self._format_results(ids, results, yaml=True, begin=begin),
**self._yaml_kwargs)
print(self._format_results(ids, results, yaml=True, begin=begin), **self._yaml_kwargs)

def _get_fluxes_names_to_print(self):
"""
Expand Down Expand Up @@ -3181,8 +3175,7 @@ def _parse_results_MultiNest_multimodal(self):
if self._yaml_results:
print(out, **self._yaml_kwargs)
if self._return_fluxes:
print("Fitted parameters and fluxes (source and blending) "
"plus best model info:")
print("Fitted parameters and fluxes (source and blending) plus best model info:")
else:
print("Fitted parameters:")

Expand Down Expand Up @@ -3212,17 +3205,14 @@ def _parse_results_MultiNest_multimodal_one_mode(self, i_mode):
self._print_results(samples, mode=i_mode)

if self._yaml_results:
fmt = ("MODE {:}:\n probability: {:}\n "
"probability_sigma: {:}\n Fitted parameters: ")
print(fmt.format(i_mode+1, probability, err),
end="", **self._yaml_kwargs)
fmt = ("MODE {:}:\n probability: {:}\n probability_sigma: {:}\n Fitted parameters: ")
print(fmt.format(i_mode+1, probability, err), end="", **self._yaml_kwargs)
self._print_yaml_results(samples, mode=i_mode)

if self._return_fluxes:
self._print_results(fluxes, names="fluxes")
if self._yaml_results:
print(" Fitted fluxes: # source and blending ", end="",
**self._yaml_kwargs)
print(" Fitted fluxes: # source and blending ", end="", **self._yaml_kwargs)
self._print_yaml_results(fluxes, names="fluxes")

print("{:.4f}".format(mode['chi2']))
Expand All @@ -3249,8 +3239,7 @@ def _parse_results_MultiNest_singlemode(self):
flux_samples = self._get_fluxes_to_print_MultiNest()
self._print_results(flux_samples, names='fluxes')
if self._yaml_results:
print("Fitted fluxes: # (source and blending)",
**self._yaml_kwargs)
print("Fitted fluxes: # (source and blending)", **self._yaml_kwargs)
self._print_yaml_results(flux_samples, names='fluxes')

def _set_mode_probabilities(self):
Expand Down

0 comments on commit 328d4f8

Please sign in to comment.