Skip to content

Commit

Permalink
ex16: _get_example_parameters() - moving fixed parameters to begin in…
Browse files Browse the repository at this point in the history
… order to prepare future commits
  • Loading branch information
rpoleski committed Jun 20, 2022
1 parent 4c97c22 commit 574b8a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions examples/example_16/TO_DO.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- posterior files
- print model
- example with add_2450000: False
- yaml output in README.md

# NOW - plot trajectory:
- test if works in ulens_model_plot.py
Expand Down
19 changes: 10 additions & 9 deletions examples/example_16/ulens_model_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
except Exception:
raise ImportError('\nYou have to install MulensModel first!\n')

__version__ = '0.30.0'
__version__ = '0.30.1'


class UlensModelFit(object):
Expand Down Expand Up @@ -1498,19 +1498,24 @@ def _get_example_parameters(self):
Generate parameters *dict* according to provided starting and fixed
parameters.
"""
if self._fixed_parameters is None:
parameters = dict()
else:
parameters = {**self._fixed_parameters}

if self._task == 'plot':
parameters = dict(zip(
parameters.update(dict(zip(
self._model_parameters['parameters'],
self._model_parameters['values']))
self._model_parameters['values'])))
# XXX this is some kind of a hack:
self._best_model_theta = []
self._fit_parameters = []
elif self._task == 'fit':
if self._fit_method == 'EMCEE':
parameters = self._get_example_parameters_EMCEE()
parameters.update(self._get_example_parameters_EMCEE())
elif self._fit_method == 'MultiNest':
means = 0.5 * (self._max_values + self._min_values)
parameters = dict(zip(self._fit_parameters, means))
parameters.update(dict(zip(self._fit_parameters, means)))
if "x_caustic_in" in self._fit_parameters:
index = self._fit_parameters.index("x_caustic_in")
parameters["x_caustic_in"] = (
Expand All @@ -1521,10 +1526,6 @@ def _get_example_parameters(self):
else:
raise ValueError('internal value')

if self._fixed_parameters is not None:
for (key, value) in self._fixed_parameters.items():
parameters[key] = value

return parameters

def _get_example_parameters_EMCEE(self):
Expand Down

0 comments on commit 574b8a1

Please sign in to comment.